Generate a makefile without a main function from Qmake - "undefined reference to `main' "
-
Thanks for your answer, yes it's my pro file that I want to build.
I added TEMPLATE += lib because I read that I need to use this variable if I want to build without a main function. -
@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.
-
Ah ! I misunderstood ! Yes, I had nothing before. I even didn't had a TEMPLATE variable.
Like you said I removed everything in the build folder, ran qmake and built but I have the same issue. -
@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
-
@NikoBir I will check (it does not build for me). But your LIBS is still wrong...
-
Ok I will correct it !
-
SGaist Lifetime Qt Championreplied to jsulm on 8 Nov 2022, 20:24 last edited by SGaist 11 Oct 2022, 19:29
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.
-
Thank you all ! It worked !!!!!
Yes the solution was TEMPLATE = lib !
12/12