Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing 3rd party librarys

Status
Not open for further replies.

dex668

Programmer
Jan 5, 2005
3
GB
Hi,

I have for a number of weeks been trying to integrate several third party librarys into a C++ application with no success, i'm sure the error is fairly simple, but i cannot for the life of me figure it out!

Libs:
- ccrtp
- jrtplib
- toast gsm

I always get 'undefined reference (...)' errors for any of the member functions i try to use. I'm using Fedora Core 3, g++ though the Eclipse IDE.

my compile line options would appear to be:
g++ -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -lpthread -lthreads

I have followed all the install instructions for these libs including ./configure, make, make install, etc.

I'm not very experienced with linux so if anyone could shed any light on this it would be extremely helpful!

Thank you all!

-Dex

---------------------
Example code snippet: AudioCodec.cpp

Code:
#include "AudioCodec.h"

#include <gsm/gsm.h>

/* Project includes */
#include "Global.h"
#include "SystemLogger.h"

gsm handle;
gsm_frame buf;
gsm_signal sample[160]; 
int cc, soundfd;

AudioCodec::AudioCodec()
{
		systemLogger = &SystemLogger::getInstance();	
}

AudioCodec::~AudioCodec()
{
}

int AudioCodec::decode()
{
	return decode(0);
}

int AudioCodec::decode( int codec )
{
	switch (codec)
	{
		case 0: 
			// gsm decode 
			if (!(handle = gsm_create())) 
*ERROR: undefined reference to `gsm_create()'	AudioCodec.cpp	server	line 34	05 January 2005 14:51:58

			{
				printf("Error: Unable to create GSM decoder");
				return 0;
			}
			
            if (gsm_decode(handle, buf, sample) < 0) return 0;
*ERROR: undefined reference to `gsm_decode(gsm_state*, unsigned char*, short*)'	AudioCodec.cpp	server	line 40	05 January 2005 14:51:58

 
            gsm_destroy(handle);
ERROR: undefined reference to `gsm_destroy(gsm_state*)'	AudioCodec.cpp	server	line 42	05 January 2005 14:51:58

			
			break;
		default:
			systemLogger->addToSystemLog("AudioCodec::No codec selected");
			printf("Error: No codec selected");
	}
	
	return 0;
}
 
> g++ -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -lpthread -lthreads
You need more libraries, and possibly some library paths depending on where your "make install" put the 3rd party libraries.

If you have say "libfoo.a" in some non-standard library directory, then the command line would become
[tt]g++ -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -lpthread -lthreads -L/path/to/library -lfoo[/tt]

The [tt]-lfoo[/tt] specifies a library called libfoo.a
The [tt]-L/path/to/library[/tt] tells the linker where libfoo.a can be found.

--
 
Salem, thanks for your prompt reply, it's much appreciated.

I have tried doing as you suggest, adding -lgsm to the compile path. However the same errors persist.

I have removed references to all libraries apart from the GSM one. i have also checked my system folders, the relevant files do exist:

- /usr/local/lib
- libgsm.a
- /usr/local/include/
- /gsm/gsm.h

below is the output from my eclipse based compilation:



**** Incremental build of configuration Debug for project server ****

make -k all
Building file: ../AudioCodec.cpp
g++ -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -lpthread -lthreads -lgsm -o AudioCodec.o ../AudioCodec.cpp
g++: -lpthread: linker input file unused because linking not done
g++: -lthreads: linker input file unused because linking not done
g++: -lgsm: linker input file unused because linking not done
g++: -lpthread: linker input file unused because linking not done
g++: -lthreads: linker input file unused because linking not done
g++: -lgsm: linker input file unused because linking not done
Finished building: ../AudioCodec.cpp

Building target: server
g++ -L/usr/local/lib -o server AdminConn.o AdminCore.o AudioCodec.o AudioConn.o ClientThread.o Core.o DataConn.o GSM.o Interpreter.o Multiplexer.o PlugIn.o SystemLogger.o main.o -lpthread -lgsm -lthreads
/usr/bin/ld: warning: libstdc++.so.5, needed by /usr/local/lib/libthreads.so, may conflict with libstdc++.so.6
AudioCodec.o(.text+0x10c): In function `AudioCodec::decode(int)':
../AudioCodec.cpp:35: undefined reference to `gsm_create()'
AudioCodec.o(.text+0x14b):../AudioCodec.cpp:41: undefined reference to `gsm_decode(gsm_state*, unsigned char*, short*)'
AudioCodec.o(.text+0x169):../AudioCodec.cpp:43: undefined reference to `gsm_destroy(gsm_state*)'
collect2: ld returned 1 exit status
make: *** [server] Error 1
make: Target `all' not remade because of errors.
Build complete for project server


Thank you again for your help.

Dex
 
Thanks for your help Salem, i appear to have resolved the issue, the file permissions on the lib file were messed up meaning g++ couldnt access it during compilation.

Cheers,

Dex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top