Undefined link for libpq functions

I have two projects, one of which is a library that uses libpq headers and an executable that references my library and libpq, but no matter how I put it into the makefile, it just doesn't link libpq and aways return me undefined link error. It binds my lib ok.

g++  -o MYAPP  main.o -L../Libs -lpq -lMYLIB

both libpq.a and libmylib.a are in the Libs directory.
I used nm to test functions, and they are, I changed -lpq to -lpq_, and the compiler complains about the missing lib, so it finds and theoretically binds, but cannot find the links?

does it really erode me, what could it be?

(my english is not so good, sorry)

Thanks
Jonathan

+3
source share
1 answer

I quickly checked out some of the postgre headers I'm flying over, and they don't seem to end up extern "C"compiling with the C ++ compiler. Is it possible that your problem will be solved by including include statements for postgre headers in the block extern "C" { ... }?

. , : libpq.a and libmylib.a. , . -lpq gcc, . -L, . , . , . , , . apt-get, , , ( ldd /usr/lib/libpq.so). , , , -lpq -lMYLIB , libpq.

+3

Source: https://habr.com/ru/post/1776025/


All Articles