sonick | salut,
j'ai écris un programme qui utilise la librairie pthread. Il se compile très bien sous Windows, mais pas sous Linux.
Voici ma ligne de compilation :
Code :
- gcc -g -Wall -o service main.c thread_clock.c thread_led.c thread_machine.c -I./postgresql-8.3.5/src/include/ -I./postgresql-8.3.5/src/interfaces/libpq/ -I./pthreads-w32-2-8-0-release/ -L./pthreads-w32-2-8-0-release/lib/ -L/usr/lib/ -lpq -lpthread -DDEBUG
|
et le résultat :
Code :
- In file included from ./pthreads-w32-2-8-0-release/pthread.h:288,
- from main.h:31,
- from main.c:21:
- ./pthreads-w32-2-8-0-release/sched.h:70:3: error: #error Please upgrade your GNU compiler to one that supports __declspec.
- In file included from ./pthreads-w32-2-8-0-release/pthread.h:288,
- from main.h:31,
- from main.c:21:
- ./pthreads-w32-2-8-0-release/sched.h:146: warning: return type defaults to 'int'
- ./pthreads-w32-2-8-0-release/sched.h: In function '__declspec':
- ./pthreads-w32-2-8-0-release/sched.h:146: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'sched_yield'
- ./pthreads-w32-2-8-0-release/sched.h:148: error: expected declaration specifiers before '__declspec'
- ./pthreads-w32-2-8-0-release/sched.h:150: error: expected declaration specifiers before '__declspec'
- ./pthreads-w32-2-8-0-release/sched.h:152: error: expected declaration specifiers before '__declspec'
- ./pthreads-w32-2-8-0-release/sched.h:154: error: expected declaration specifiers before '__declspec'
- In file included from main.h:31,
- from main.c:21:
- ./pthreads-w32-2-8-0-release/pthread.h:307: warning: empty declaration
- In file included from main.h:31,
- from main.c:21:
- ./pthreads-w32-2-8-0-release/pthread.h:527:3: error: #error Please upgrade your GNU compiler to one that supports __declspec.
- ./pthreads-w32-2-8-0-release/pthread.h:569: error: storage class specified for parameter 'ptw32_handle_t'
- ./pthreads-w32-2-8-0-release/pthread.h:571: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pthread_t'
- ./pthreads-w32-2-8-0-release/pthread.h:572: error: storage class specified for parameter 'pthread_attr_t'
- ./pthreads-w32-2-8-0-release/pthread.h:573: error: storage class specified for parameter 'pthread_once_t'
- ./pthreads-w32-2-8-0-release/pthread.h:574: error: storage class specified for parameter 'pthread_key_t'
- ./pthreads-w32-2-8-0-release/pthread.h:575: error: storage class specified for parameter 'pthread_mutex_t'
- ./pthreads-w32-2-8-0-release/pthread.h:576: error: storage class specified for parameter 'pthread_mutexattr_t'
- ./pthreads-w32-2-8-0-release/pthread.h:577: error: storage class specified for parameter 'pthread_cond_t'
- ./pthreads-w32-2-8-0-release/pthread.h:578: error: storage class specified for parameter 'pthread_condattr_t'
- ./pthreads-w32-2-8-0-release/pthread.h:580: error: storage class specified for parameter 'pthread_rwlock_t'
- ./pthreads-w32-2-8-0-release/pthread.h:581: error: storage class specified for parameter 'pthread_rwlockattr_t'
- ./pthreads-w32-2-8-0-release/pthread.h:582: error: storage class specified for parameter 'pthread_spinlock_t'
- ...
|
Si j'omet d'inclure pthread, voici ce qui se passe :
Code :
- gcc -g -Wall -o service main.c thread_clock.c thread_led.c thread_machine.c -I./postgresql-8.3.5/src/include/ -I./postgresql-8.3.5/src/interfaces/libpq/ -L./pthreads-w32-2-8-0-release/lib/ -L/usr/lib/ -lpq -lpthread -DDEBUG svn: warning: cannot set LC_CTYPE locale
- svn: warning: environment variable LANG is fr_FR.UTF-8
- svn: warning: please check that your locale name is correct
- At revision 878.
- thread_clock.c: In function 'thread_clock':
- thread_clock.c:102: warning: implicit declaration of function 'pthread_delay_np'
- thread_led.c: In function 'thread_led':
- thread_led.c:61: warning: implicit declaration of function 'pthread_delay_np'
- thread_machine.c: In function 'thread_machine':
- thread_machine.c:37: warning: implicit declaration of function 'pthread_delay_np'
- thread_machine.c: In function 'ParseEvents':
- thread_machine.c:223: warning: statement with no effect
- /tmp/ccEPYS1Z.o: In function `thread_clock':
- /home/linux/Desktop/service_C2/service_C_v2/thread_clock.c:27: undefined reference to `cmd_19CLK'
- /home/linux/Desktop/service_C2/service_C_v2/thread_clock.c:75: undefined reference to `cmd_19CLK_UPDATE'
- /home/linux/Desktop/service_C2/service_C_v2/thread_clock.c:82: undefined reference to `cmd_19CLK'
- /home/linux/Desktop/service_C2/service_C_v2/thread_clock.c:102: undefined reference to `pthread_delay_np'
- /tmp/cckvQVKv.o: In function `thread_led':
- /home/linux/Desktop/service_C2/service_C_v2/thread_led.c:61: undefined reference to `pthread_delay_np'
- /home/linux/Desktop/service_C2/service_C_v2/thread_led.c:89: undefined reference to `cmd_19PREVENTIVE'
- /home/linux/Desktop/service_C2/service_C_v2/thread_led.c:104: undefined reference to `pthread_delay_np'
- /tmp/cccxYmWm.o: In function `thread_machine':
- /home/linux/Desktop/service_C2/service_C_v2/thread_machine.c:37: undefined reference to `pthread_delay_np'
- /home/linux/Desktop/service_C2/service_C_v2/thread_machine.c:54: undefined reference to `pthread_delay_np'
- /home/linux/Desktop/service_C2/service_C_v2/thread_machine.c:95: undefined reference to `pthread_delay_np'
- /home/linux/Desktop/service_C2/service_C_v2/thread_machine.c:114: undefined reference to `cmd_19EVTS_RETRIEVE'
- /home/linux/Desktop/service_C2/service_C_v2/thread_machine.c:140: undefined reference to `pthread_delay_np'
- collect2: ld returned 1 exit status
|
J'ai vérifié plusieurs fois ma ligne de compil et les chemins, et tout correspond... Voyez vous l'origine de mon problème ?
Merci Message édité par sonick le 30-01-2009 à 15:09:38
|