使用gcc编译c代码的时候报错
今天编译erlang自带的ei_interface的例子时,报错如下
[liufan@liufan src]$ gcc -o extprg -I/usr/local/lib/erlang/lib/erl_interface-3.7.13/include/ -L/usr/local/lib/erlang/lib/erl_interface-3.7.13/lib complex.c erl_comm.c ei.c -lerl_interface -lei/usr/local/lib/erlang/lib/erl_interface-3.7.13/lib/libei.a(ei_pthreads.o): In function `__erl_errno_place':/home/liufan/workspace/sourceCode/otp_src_R16B01/lib/erl_interface/src/misc/ei_pthreads.c:194: undefined reference to `pthread_once'/home/liufan/workspace/sourceCode/otp_src_R16B01/lib/erl_interface/src/misc/ei_pthreads.c:200: undefined reference to `pthread_getspecific'/home/liufan/workspace/sourceCode/otp_src_R16B01/lib/erl_interface/src/misc/ei_pthreads.c:209: undefined reference to `pthread_setspecific'/home/liufan/workspace/sourceCode/otp_src_R16B01/lib/erl_interface/src/misc/ei_pthreads.c:210: undefined reference to `pthread_getspecific'/usr/local/lib/erlang/lib/erl_interface-3.7.13/lib/libei.a(ei_pthreads.o): In function `erl_errno_key_alloc':/home/liufan/workspace/sourceCode/otp_src_R16B01/lib/erl_interface/src/misc/ei_pthreads.c:171: undefined reference to `pthread_key_create'/usr/local/lib/erlang/lib/erl_interface-3.7.13/lib/libei.a(ei_pthreads.o): In function `ei_m_trylock':/home/liufan/workspace/sourceCode/otp_src_R16B01/lib/erl_interface/src/misc/ei_pthreads.c:138: undefined reference to `pthread_mutex_trylock'collect2: ld returned 1 exit status
[liufan@liufan src]$ gcc -o extprg -I/usr/local/lib/erlang/lib/erl_interface-3.7.13/include/ -L/usr/local/lib/erlang/lib/erl_interface-3.7.13/lib complex.c erl_comm.c ei.c -lerl_interface -lei -lpthread[liufan@liufan src]$
Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]Eshell V5.10.2 (abort with ^G)1> c(complex2).complex2.erl:43: Warning: variable 'Reason' is unused{ok,complex2}2> compcompile complex2 2> complex2:start("extprg").<0.40.0>3> sh: line 0: exec: extprg: not found
Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]Eshell V5.10.2 (abort with ^G)1> complex2:start("./extprg").<0.34.0>2> 2> complex2:foo(3).43> complex2:bar(5).104> complex2:st start/1 stop/0 4> complex2:stop().stop