Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


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

Rep: Reputation: 0
The problem when I want to compile my Qt program,help

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
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?
Old 05-11-2006, 06:52 AM   #2
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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, 04:24 AM   #3
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, 07:24 AM   #4
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, 07:42 AM   #5
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148


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 02:38 AM
Can't compile c++ program eg_wwkaa Programming 34 06-18-2003 09:59 PM
Compile qt program. hfawzy Linux - General 2 02-18-2003 11:25 AM
compile C program juno Linux - Software 4 09-27-2002 01:29 PM
compile program Eddie9 Linux - General 1 05-21-2002 11:11 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:20 PM.

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