LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   The problem when I want to compile my Qt program,help (https://www.linuxquestions.org/questions/programming-9/the-problem-when-i-want-to-compile-my-qt-program-help-443658/)

zhuqlfeixia 05-10-2006 09:27 PM

The problem when I want to compile my Qt program,help
 
Hi,bodies:)
Several days ago, I write a program to Sniffer on the network. And I used the libpcap to capture the packets. The program is under the console,so when I compile the program, I just write:

g++ -o myprogram myprogram.cpp -L/usr/local/libpcap-0.9.4 -lpcap -lnet -lpthread

Beacuse I used the libpcap,libnet,pthread, so I wrote -lpcap,-lnet,-lpthread. And my libpcap is in the /usr/local,so I wrote -L/usr/local/libpcap-0.9.4, then I compile it successfully.

But now, I want the program to be visualization, and I want to use Qt/KDE to finish it. So I use the "Qt Designer", but the problem appears, that is where should I write the scentence:
"-L/usr/local/libpcap-0.9.4 -lpcap -lnet -lpthread".

The method to compile the Qt program is:
First, make a new file named "main.cpp", then type the scentence below in the console to make a Makefile:
qmake -o Makefile myprogram.pro
Now type the "make" in the console to compile. At last type ./myprogram, the program should run successfully.

If the program is a simple one,the method above is OK,but I must use -lpcap,-lbnet,lpthread, and I don't know where to write it.
So some functions in the libpcap and libnet and so on is can't be compiled.
Could somebody tell me how to solve the problem?
Thanks.

graemef 05-11-2006 05:52 AM

You want to edit your .pro file. Take a look at the qmake documentation. In sort add a LIBS section to the project file, then run qmake.

gkiagia 05-12-2006 03:24 AM

OR run qmake and then edit the generated makefile.
There is a variable in the makefile called something like LDLIBS or something similar (I don't have a makefile right now in front of me and I don't remember how it is called.)

This is not a good tactic, though, if you want to distribute the source code. The best solution is to edit your .pro file.

zhuqlfeixia 05-12-2006 06:24 AM

Oh,I find there is a something like "Libs",and I add the sentence,then It's OK, Thanks:)

graemef 05-12-2006 06:42 AM

Excellent!


All times are GMT -5. The time now is 09:31 AM.