compile/linker problem with simple libipq code
For some reason, my simply code is not linking, and I don't know why. The libipq library is there, it contains the functions which the linker says fail, so I'm at a loss. Hopefully it's something stupid I'm overlooking. (=
Quote:
Anyone have an idea? |
And how exactly are you building your test program? For the linking to be successful, two conditions must be met: The library containing the symbol must be in the directories searched by the linker and you must explicitly tell the linker to link the library.
|
If you'll look right below the segment of code, I showed the
gcc line I ran to attempt compilation/linking. Although unnecessary, I included -L/usr/lib (where the libipq library is housed). The only thing that I am thinking is that maybe the linker is looking for the shared library, which I don't have installed. I guess I'll see about compiling it. Maybe that's the problem. ------ edit ------------ Looks like the install package only makes static libs. Oh well, it was a thought. |
Nevermind, I see it now.
Try this makefile: Code:
CC = gcc |
I was too quick to reply. Please see my edited version.
|
Thanks for the heads up and makefile example. However, I found my error. I knew that order was very important to gcc, but didn't realize that it would affect my prog like this.
Basically, -lipq needs to come AFTER the .c source. Don't ask me why, but when I compile it as: Quote:
::shaking head:: |
Yeah, that's what I suspected and therefore gave you a Makefile (I always use Makefiles) that I knew would work. In your previous command line you were passing the library option to the compiler, not the linker.
|
Quote:
Per gcc's man page: Quote:
|
All times are GMT -5. The time now is 01:23 AM. |