posts - 88, comments - 3, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

axis2/c的hello.c编译不过的原因

Posted on 2015-08-18 17:59 Milo的海域 阅读(331) 评论(0)  编辑  收藏 所属分类: LinuxC
http://axis.apache.org/axis2/c/core/docs/axis2c_manual.html#client_api 的hello.c client 编译命令在我的ubuntu 12.04s上总是报错
gcc -o hello -I$AXIS2C_HOME/include/axis2-1.6.0/ -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -laxis2_engine -lpthread -laxis2_http_sender -laxis2_http_receiver -ldl -Wl,--rpath -Wl,$AXIS2C_HOME/lib hello.c
/tmp/ccCYikFh.o: In function `main':
hello.c:(.text+0x57): undefined reference to `axutil_env_create_all'
hello.c:(.text+0x68): undefined reference to `axis2_options_create'
hello.c:(.text+0x93): undefined reference to `axutil_strcmp'
hello.c:(.text+0xeb): undefined reference to `axis2_endpoint_ref_create'
hello.c:(.text+0x102): undefined reference to `axis2_options_set_to'
hello.c:(.text+0x13d): undefined reference to `axis2_svc_client_create'
hello.c:(.text+0x168): undefined reference to `axutil_error_get_message'
hello.c:(.text+0x193): undefined reference to `axutil_log_impl_log_error'
hello.c:(.text+0x1b1): undefined reference to `axis2_svc_client_set_options'
hello.c:(.text+0x1d6): undefined reference to `axis2_svc_client_send_receive'
hello.c:(.text+0x21d): undefined reference to `axiom_node_free_tree'
hello.c:(.text+0x238): undefined reference to `axutil_error_get_message'
hello.c:(.text+0x266): undefined reference to `axutil_log_impl_log_error'
hello.c:(.text+0x28d): undefined reference to `axis2_svc_client_free'
hello.c:(.text+0x2a8): undefined reference to `axutil_env_free'
/tmp/ccCYikFh.o: In function `build_om_request':
hello.c:(.text+0x2ed): undefined reference to `axiom_element_create'
hello.c:(.text+0x307): undefined reference to `axiom_element_set_text'
/tmp/ccCYikFh.o: In function `process_om_response':
hello.c:(.text+0x337): undefined reference to `axiom_node_get_first_child'
hello.c:(.text+0x351): undefined reference to `axiom_node_get_node_type'
hello.c:(.text+0x367): undefined reference to `axiom_node_get_data_element'
hello.c:(.text+0x381): undefined reference to `axiom_text_get_value'
hello.c:(.text+0x396): undefined reference to `axiom_text_get_value'
collect2: error: ld returned 
1 exit status
仔细检查了gcc命令,头文件,库文件的路径都是对的,最后跟同事讨论才发现hello.c的位置的问题。。如果hello.c的位置放到了依赖库的右面 就会报类似错误。但是官方的例子应该是测试过的,怎么会有这个问题呢? 难道我的ubuntu 12.04的gcc比较严格?

修正后的gcc命令如下
gcc -o hello hello.c  -I$AXIS2C_HOME/include/axis2-1.6.0/ -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -laxis2_engine -lpthread -laxis2_http_sender -laxis2_http_receiver -ldl -Wl,--rpath -Wl,$AXIS2C_HOME/lib

只有注册用户登录后才能发表评论。


网站导航: