LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-10-2006, 09:27 PM   #1
zhuqlfeixia
LQ Newbie
 
Registered: Dec 2005
Posts: 19

Rep: Reputation: 0
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.
 
Old 05-11-2006, 05:52 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,376

Rep: Reputation: 147Reputation: 147
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.
 
Old 05-12-2006, 03:24 AM   #3
gkiagia
Member
 
Registered: Oct 2003
Location: Greece
Distribution: Debian sid
Posts: 248

Rep: Reputation: 30
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.
 
Old 05-12-2006, 06:24 AM   #4
zhuqlfeixia
LQ Newbie
 
Registered: Dec 2005
Posts: 19

Original Poster
Rep: Reputation: 0
Oh,I find there is a something like "Libs",and I add the sentence,then It's OK, Thanks
 
Old 05-12-2006, 06:42 AM   #5
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,376

Rep: Reputation: 147Reputation: 147
Excellent!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
squareroot program problem, i cant compile it ARGH! inverted.gravity Programming 5 02-15-2006 01:38 AM
Can't compile c++ program eg_wwkaa Programming 34 06-18-2003 08:59 PM
Compile qt program. hfawzy Linux - General 2 02-18-2003 10:25 AM
compile C program juno Linux - Software 4 09-27-2002 12:29 PM
compile program Eddie9 Linux - General 1 05-21-2002 10:11 PM


All times are GMT -5. The time now is 12:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration