User forums > Using Code::Blocks

How to link a .o file to a project

<< < (2/2)

oBFusCATed:
Use "nm" command line tool to find what symbols the object file has.

MortenMacFly:

--- Quote from: oBFusCATed on January 24, 2010, 05:36:29 pm ---Use "nm" command line tool to find what symbols the object file has.

--- End quote ---
Hey - there is the "symbol table" plugin (a wrapper around nm) that does this more nicely and is integrated into C::B. ;-)

greenninja:
Well I added the .o file to the linker like Jens suggested, and it seems to be ok, the errors for it no longer assert, but I also have a .a file that needs to be included as well, so now I am trying to compile that into a .o file and include it as well.  I have tried including it similarly to a .cpp or .c file and tell it to link / compile but all attempts i get at this result in an error log similar to this.

mingw32-gcc.exe -Wall -W -g -c "C:\Users\Joshua\Desktop\College\EECS 482\Proj 1 Threads\Threads\Sample Thread\libinterrupt.a" -o obj\Debug\libinterrupt.o
mingw32-gcc.exe: C:\Users\Joshua\Desktop\College\EECS 482\Proj 1 Threads\Threads\Sample Thread\libinterrupt.a: linker input file unused because linking not done
mingw32-g++.exe -o "bin\Debug\Sample Thread.exe" obj\Debug\main.o thread.o obj\Debug\libinterrupt.o
mingw32-g++.exe: obj\Debug\libinterrupt.o: No such file or directory

additionally for the project spec when running this on a linux remote terminal the command line to run this is:

g++ -m32 thread.o main.cc libinterrupt.a -ldl

When I run this with my files on a linux remote terminal it runs perfect, so the .a and .o files are complete, so I am the one messing this up lol.  I have searched the internet for those compile flags and can't find anything.  If anybody has any further suggestions for the .a file issues, I'd greatly appreciate the help.  I thought it was working but apparently the .o file problems were asserting first so I didn't realize it was a problem.

Thanks in advance!

oBFusCATed:
.a file is a static lib (an Ar archive with object files).
Add it in the linker option as any other lib.

Navigation

[0] Message Index

[*] Previous page

Go to full version