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. |
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.
|
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. |
Oh,I find there is a something like "Libs",and I add the sentence,then It's OK, Thanks:)
|
Excellent!
|
All times are GMT -5. The time now is 09:31 AM. |