Generate a makefile without a main function from Qmake - "undefined reference to `main' "
-
@NikoBir said in Generate a makefile without a main function from Qmake - "undefined reference to `main' ":
I added TEMPLATE += lib because I read that I need to use this variable if I want to build without a main function
That is clear. My question is whether you had something else there and then changed to lib. If that's the case then delete everything in build folder, run qmake and build.
-
@NikoBir said in Generate a makefile without a main function from Qmake - "undefined reference to `main' ":
LIBS += /usr/lib/libprotobuf.so
This line is wrong please seee here how to do it properly: https://doc.qt.io/qt-6/qmake-variable-reference.html#libs), but not the cause for your issue I think.
Can you provide a minimal reproducible project, so others can try? -
Thank you, yes I can !
I created this repository with my zipped project. I added the includes and libs.https://github.com/QtForumHelp/undefined_reference_to_main_Qmake-Protobuf
-
Hi,
@jsulm said in Generate a makefile without a main function from Qmake - "undefined reference to `main' ":
@NikoBir said in Generate a makefile without a main function from Qmake - "undefined reference to `main' ":
I added TEMPLATE += lib because I read that I need to use this variable if I want to build without a main function
That is clear. My question is whether you had something else there and then changed to lib. If that's the case then delete everything in build folder, run qmake and build.
In addition to what @jsulm, TEMPLATE should contain a single value. Here you likely have something else. So just in case, replace it with
TEMPLATE = lib
. -
@SGaist wrote:
TEMPLATE should contain a single value. Here you likely something else. So just in case, replace it with
TEMPLATE = lib
.Indeed, as per the docs,
TEMPLATE
defaults toapp
. So by using+=
theTEMPLATE
ends up beingapp lib
, which is not what you want :)So, as @SGaist indicated, drop the
+
from that line so:TEMPLATE = lib
Cheers.