[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem linking C++ applications to libquran



Hi

In your header file:
at the beginning include:

#ifdef __cplusplus
extern "C"
{
#endif

and at the end:

#ifdef  __cplusplus
}
#endif

To turn off mangling.


On Sun, 1 Dec 2002, Mohammed Yousif wrote:

> Salam,
> I'm facing a problem that makes me unable to link qtquran against
> libquran or even anyother C++ program.
> I wrote a minimal C++ application:
> test.cpp:
> #include <quran.h>
> int main() {
>     int i=0;
>     i=quran_init();
>     return 0;
> }
> 
> 
> but when ever I compile it, it compiles fine but the linker fails to link it
> against libquran
> 
> g++ test.cpp
> /tmp/ccyQxJtF.o: In function `main':
> /tmp/ccyQxJtF.o(.text+0xe): undefined reference to `quran_init(void)'
> collect2: ld returned 1 exit status
> 
> g++ test.cpp  -lquran
> /tmp/ccyQxJtF.o: In function `main':
> /tmp/ccyQxJtF.o(.text+0xe): undefined reference to `quran_init(void)'
> collect2: ld returned 1 exit status
> 
> g++ -c test.cpp
> 
> g++ test.o -lquran
> ld: warning: cannot find entry symbol _start; defaulting to 0000000008048080
> test.o: In function `main':
> test.o(.text+0xe): undefined reference to `quran_init(void)'
> 
> g++ test.o libquran.a
> ld: warning: cannot find entry symbol _start; defaulting to 0000000008048080
> test.o: In function `main':
> test.o(.text+0xe): undefined reference to `quran_init(void)'
> 
> and the funny thing that test.cpp doesn't call any function rather
> than quran_init(void) but the linker argues that there are undefined
> references to expat functions, speex functions ....etc, those functions
> are called in libquran itself!
> 
> ld test.o quran.o
> ld: warning: cannot find entry symbol _start; defaulting to 0000000008048080
> test.o: In function `main':
> test.o(.text+0xe): undefined reference to `quran_init(void)'
> quran.o: In function `callback_start':
> quran.c:139: undefined reference to `strncmp'
> quran.c:141: undefined reference to `strncmp'
> quran.c:142: undefined reference to `__strdup'
> quran.c:150: undefined reference to `strncmp'
> quran.c:152: undefined reference to `strncmp'
> quran.c:153: undefined reference to `__strdup'
> quran.c:161: undefined reference to `strncmp'
> quran.c:166: undefined reference to `strncmp'
> quran.o: In function `callback_end':
> quran.c:180: undefined reference to `strncmp'
> quran.c:183: undefined reference to `stderr'
> quran.c:183: undefined reference to `fprintf'
> quran.c:190: undefined reference to `strncmp'
> quran.o: In function `callback_cdata':
> quran.c:207: undefined reference to `malloc'
> quran.c:210: undefined reference to `strndup'
> quran.c:227: undefined reference to `malloc'
> quran.c:230: undefined reference to `strndup'
> quran.o: In function `free_aya':
> quran.c:256: undefined reference to `free'
> quran.c:257: undefined reference to `free'
> quran.o: In function `build_sura':
> quran.c:272: undefined reference to `malloc'
> quran.c:279: undefined reference to `XML_ParserCreate'
> quran.c:280: undefined reference to `XML_SetElementHandler'
> quran.c:281: undefined reference to `XML_SetCharacterDataHandler'
> quran.c:283: undefined reference to `XML_SetUserData'
> quran.c:286: undefined reference to `XML_GetBuffer'
> quran.c:291: undefined reference to `fread'
> quran.c:299: undefined reference to `XML_ParseBuffer'
> quran.c:304: undefined reference to `free'
> quran.c:305: undefined reference to `XML_ParserFree'
> quran.o: In function `callback_start_config':
> quran.c:311: undefined reference to `strncmp'
> quran.c:312: undefined reference to `strncmp'
> quran.c:313: undefined reference to `strncmp'
> quran.c:315: undefined reference to `strncmp'
> quran.c:317: undefined reference to `__strdup'
> quran.c:321: undefined reference to `strncmp'
> quran.c:323: undefined reference to `strncmp'
> quran.c:325: undefined reference to `__strdup'
> quran.o: In function `callback_end_config':
> quran.c:333: undefined reference to `strncmp'
> quran.c:334: undefined reference to `strncmp'
> quran.o: In function `select_xml_file':
> quran.c:347: undefined reference to `strncmp'
> quran.c:349: undefined reference to `strstr'
> quran.o: In function `quran_init':
> quran.c:380: undefined reference to `XML_ParserCreate'
> quran.c:381: undefined reference to `XML_SetElementHandler'
> quran.c:382: undefined reference to `XML_SetCharacterDataHandler'
> quran.c:383: undefined reference to `fopen'
> quran.c:384: undefined reference to `fopen'
> quran.c:385: undefined reference to `fopen'
> quran.c:386: undefined reference to `fopen'
> quran.c:387: undefined reference to `fopen'
> quran.o:quran.c:388: more undefined references to `fopen' follow
> quran.o: In function `quran_init':
> quran.c:393: undefined reference to `XML_GetBuffer'
> quran.c:398: undefined reference to `fread'
> quran.c:406: undefined reference to `XML_ParseBuffer'
> quran.c:411: undefined reference to `fclose'
> quran.c:414: undefined reference to `malloc'
> quran.c:414: undefined reference to `memcpy'
> quran.c:417: undefined reference to `malloc'
> quran.c:417: undefined reference to `memcpy'
> quran.c:418: undefined reference to `alphasort'
> quran.c:418: undefined reference to `scandir'
> quran.c:420: undefined reference to `puts'
> quran.c:422: undefined reference to `malloc'
> quran.c:425: undefined reference to `strstr'
> quran.c:426: undefined reference to `strndup'
> quran.c:423: undefined reference to `free'
> quran.c:429: undefined reference to `free'
> quran.c:431: undefined reference to `free'
> quran.c:435: undefined reference to `malloc'
> quran.c:436: undefined reference to `opendir'
> quran.c:442: undefined reference to `malloc'
> quran.c:444: undefined reference to `malloc'
> quran.c:446: undefined reference to `sprintf'
> quran.c:449: undefined reference to `realloc'
> quran.c:451: undefined reference to `__strdup'
> quran.c:455: undefined reference to `realloc'
> quran.c:456: undefined reference to `opendir'
> quran.c:457: undefined reference to `free'
> quran.c:462: undefined reference to `realloc'
> quran.c:464: undefined reference to `stderr'
> quran.c:464: undefined reference to `fprintf'
> quran.c:466: undefined reference to `exit'
> quran.c:467: undefined reference to `__strdup'
> quran.c:470: undefined reference to `readdir'
> quran.c:471: undefined reference to `closedir'
> quran.c:473: undefined reference to `free'
> quran.c:477: undefined reference to `realloc'
> quran.c:488: undefined reference to `readdir'
> quran.c:489: undefined reference to `closedir'
> quran.c:493: undefined reference to `free'
> quran.c:497: undefined reference to `free'
> quran.c:498: undefined reference to `XML_ParserFree'
> quran.o: In function `quran_open':
> quran.c:518: undefined reference to `malloc'
> quran.c:520: undefined reference to `__strdup'
> quran.c:521: undefined reference to `malloc'
> quran.c:528: undefined reference to `sprintf'
> quran.c:534: undefined reference to `fopen'
> quran.c:538: undefined reference to `fclose'
> quran.c:539: undefined reference to `free'
> quran.c:530: undefined reference to `free'
> quran.c:532: undefined reference to `free'
> quran.o: In function `quran_close':
> quran.c:554: undefined reference to `free'
> quran.c:568: undefined reference to `free'
> quran.o:quran.c:569: more undefined references to `free' follow
> quran.o: In function `quran_read_verse':
> quran.c:629: undefined reference to `__strdup'
> quran.o: In function `quran_sura_info':
> quran.c:642: undefined reference to `malloc'
> quran.o: In function `quran_verse_info':
> quran.c:661: undefined reference to `malloc'
> quran.o: In function `process_header':
> quran.c:713: undefined reference to `speex_packet_to_header'
> quran.c:730: undefined reference to `speex_mode_list'
> quran.c:738: undefined reference to `stderr'
> quran.c:738: undefined reference to `fprintf'
> quran.c:742: undefined reference to `speex_decoder_init'
> quran.c:743: undefined reference to `speex_decoder_ctl'
> quran.c:745: undefined reference to `speex_decoder_ctl'
> quran.c:747: undefined reference to `speex_std_stereo_request_handler'
> quran.c:750: undefined reference to `speex_decoder_ctl'
> quran.c:763: undefined reference to `speex_decoder_ctl'
> quran.c:771: undefined reference to `stderr'
> quran.c:771: undefined reference to `fprintf'
> quran.c:778: undefined reference to `stderr'
> quran.c:778: undefined reference to `fprintf'
> quran.c:779: undefined reference to `free'
> quran.o: In function `quran_audio_open':
> quran.c:811: undefined reference to `malloc'
> quran.c:812: undefined reference to `sprintf'
> quran.c:813: undefined reference to `fopen'
> quran.c:814: undefined reference to `free'
> quran.c:817: undefined reference to `malloc'
> quran.c:818: undefined reference to `ogg_sync_init'
> quran.c:819: undefined reference to `speex_bits_init'
> quran.o: In function `quran_audio_play_':
> quran.c:854: undefined reference to `stderr'
> quran.c:854: undefined reference to `fprintf'
> quran.c:866: undefined reference to `ogg_sync_buffer'
> quran.c:867: undefined reference to `fread'
> quran.c:869: undefined reference to `ogg_sync_wrote'
> quran.c:873: undefined reference to `ogg_page_serialno'
> quran.c:873: undefined reference to `ogg_stream_init'
> quran.c:878: undefined reference to `ogg_stream_pagein'
> quran.c:901: undefined reference to `rand'
> quran.c:909: undefined reference to `speex_bits_read_from'
> quran.c:917: undefined reference to `speex_decode'
> quran.c:920: undefined reference to `speex_decode_stereo'
> quran.c:924: undefined reference to `speex_decoder_ctl'
> quran.c:925: undefined reference to `stderr'
> quran.c:925: undefined reference to `fputc'
> quran.c:926: undefined reference to `stderr'
> quran.c:926: undefined reference to `fprintf'
> quran.c:936: undefined reference to `le_short'
> quran.c:945: undefined reference to `ogg_stream_packetout'
> quran.c:946: undefined reference to `ogg_sync_pageout'
> quran.c:948: undefined reference to `feof'
> quran.o: In function `quran_audio_stop':
> quran.c:985: undefined reference to `fclose'
> quran.o: In function `quran_audio_close':
> quran.c:1001: undefined reference to `free'
> 
> ld test.o quran.o -lexpat -lspeex -logg
> ld: warning: cannot find entry symbol _start; defaulting to 0000000008048df0
> test.o: In function `main':
> test.o(.text+0xe): undefined reference to `quran_init(void)'
> This problem really bothers me so Any clues ?
> 
> Thanks
> 

-- 
Behdad Esfahbod		10 Azar 1381, 2002 Dec 1 
http://behdad.org/	[Finger for Geek Code]

#define is_persian_leap(y) ((((y)-474)%2820+2820)%2820*31%128<31)