@gerd said in Building a c shared library in QtCreator:
@martyn
QMAKE_LINK = cc QMKAE_LFLAGS+= -Wl,-init,MyInit
shouldn't that be
OK - Yes the QMAKE_ versions do work :-)
@aha_1980 said in Building a c shared library in QtCreator:
@gerd is correct. The question to @Martyn is rather, why is QMAKE_LINK needed?
The question is how do I instruct it to use c to link the DSO
There is no such thing as a C or C++ linker. The linker links just symbols. If your file is compiled with a C++ compiler, then something wents wrong.
Yes - I am wanting to use gcc as the (frontend/driver for the) linker to avoid libstdc++ being linked. To confirm, the source file was always being compiled by the c compiler.
QT -= core gui TARGET = myproject TEMPLATE = lib DEFINES += MYPROJECT_LIBRARY DEFINES += QT_DEPRECATED_WARNINGS QMAKE_LFLAGS += -Wl,-init,myprojectInit #QMAKE_LINK = cc SOURCES += \ binding.c HEADERS += \ binding.h \ pebinder_global.h unix { target.path = /usr/lib INSTALLS += target }Please post the whole .pro file and the complete compile log for reference.
This provides the link step as
g++ -Wl,-init,myprojectInit -Wl,-O1 -Wl,-z,relro -shared -Wl,-soname,libmyproject.so.1 -o libmyproject.so.1.0.0 binding.o -lpthreadSo, as you say, the question is should qmake be smart enough to realise that c++ isn't needed to link if all the source files are .c.
Though I'm happy to now have a simple solution :-)