News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Include External Object File in to Project

Started by ThomasG, August 15, 2005, 05:34:33 PM

Previous topic - Next topic

ThomasG

Hi,

I just made the transition to Code::Blocks. I think is a very good program. But now I run into an issue. I imported a Visual C++ Solution in to Code::Blocks. When I try to compile it, then I get the following:

Release/dongle.o:dongle.c:(.text+0x62): undefined reference to `KFUNC'
collect2: ld returned 1 exit status
make.exe: *** [Release/IMS7_DLL.dll] Error 1


That function is declared in a header file as

// KEYBD and KFUNC are resolved by linking with KL2.OBJ
extern unsigned  KEYBD(unsigned);
extern unsigned int __cdecl far GETLASTKEYERROR(void);
extern unsigned long KFUNC(unsigned, unsigned, unsigned, unsigned);


What do I have to do, to include the KL2.obj file in the project?

It must be possible to get the project running with the GCC Compiler, since I had it once running with Dev-C++, but I don't have the sources anymore.

Thanks for any help in advance.

Regards,
Thomas

rickg22

Normally you'd have to include KL2.c (the sourcefile) in your project and let codeblocks handle the dependency stuff.

But right now, you don't have the source code, so the only solution is to make a library out of KL2 (call it KL2.LIB). And include KL2.LIB in your project's linker libraries. (See why it's better to keep the sources? ;-) )

Oh, now that I remember, I recall there's a C decompiler out there in the web. You'd get a nasty, ugly C file, but hey, at least you could recompile it! ;-)

ThomasG

I would like to have the C code, but it's a library we bought, and they will not give that source code out for several reasons. Since it is working with the Visual C++ 2003 and it was working with Dev-C++, there must be a way to get it working in Code::Blocks too. I guess, I'm missing just a setting somewhere.

Thomas

Urxae

Well, if it worked with Dev-C++, it can probably be done by going to Build options -> <your target or project> -> Linker -> Other linker options, and add whatever Dev-C++ adds to the command line in that text box.

rickg22

You did know libraries are composed out of .obj files, didn't you? I don't remember the name of the microsoft tool, but you CAN convert .obj's into .lib's.

So it's just matter of converting your .obj into .lib, and adding it to the project link libraries. object files are meant to be temporary objects (either to create libs, or exes), not to be used as libraries themselves.

grv575

Wouldn't you need to use ar.exe and ranlib.exe (gcc).

You could just try passing the name of the.o file to the linker other options as was mentioned, but be careful  - not sure if a rebuildwill delete all .o files

ThomasG

Hi,

I figured out what to do. I found my old Dev-C++ project where the stuff was working. I imported it and looked at the Linker settings. Thanks Urxae for the hint, it helped. I attached a screen shot of my settings that made it working.



Thanks for your help guys,
Thomas