LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 10-04-2008, 10:25 PM   #1
Slokunshialgo
Member
 
Registered: Jan 2006
Distribution: Ubuntu 9.04, Fedora 10
Posts: 76

Rep: Reputation: 17
C/DBus Compilation Problems


I'm trying to write a small program to use the DBus API, but I cannot get it to compile.

Code:
#include <dbus/dbus.h>

int main(int arc, char* args[]) {
	DBusError err;
	DBusConnection* conn;

	dbus_error_init(&err);
	conn = dbus_bus_get(DBUS_BUS_SESSION, &err);


	return 0;
}
When I try compiling it using gcc -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include main.c I get the following errors:

Code:
main.c:(.text+0x18): undefined reference to `dbus_error_init'
main.c:(.text+0x2b): undefined reference to `dbus_bus_get'
System: Fedora 9; x86

I have the development files installed, and when I edit the files in an editor (Anjuta, or Eclipse/CDT) the functions are suggested by their autocomplete functions, so I assume they should work.

Anybody know what I might be missing, or what I can do to make this work?
 
Old 10-05-2008, 08:59 AM   #2
Slokunshialgo
Member
 
Registered: Jan 2006
Distribution: Ubuntu 9.04, Fedora 10
Posts: 76

Original Poster
Rep: Reputation: 17
I wound up getting an answer from somebody else. I was told to run pkg-config --libs dbus-1 and include the output (-L/lib -ldbus-1) in my compilation command. This works, and it all compiles nicely.

gcc -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -L/lib -ldbus-1 main.c is the full line now.
 
1 members found this post helpful.
  


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
Problems with HAL, dbus, network after Java install... JustMeAgain Debian 6 09-13-2008 05:22 PM
Compilation problems roqin Ubuntu 2 06-16-2008 06:50 PM
C++ compilation problems madhatter301 Programming 4 03-16-2005 05:13 PM
Compilation Problems kamransoomro84 Programming 9 05-04-2004 06:39 PM
X compilation problems da Perp Linux From Scratch 2 07-16-2002 02:46 AM


All times are GMT -5. The time now is 04:56 PM.

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