我有一个 c 项目,我想用 MinGW 在 CodeBlocks 中编译它。我试图链接它所需的库,但我得到了
未定义的参考错误
于是我搜了一下,发现我使用的库是用MVC++编译的,不能和MinGW一起使用。(我不是 c 方面的专家,所以我有点困惑。)我找到了这个链接并按照他们所说的来解决我的问题。
我从原始的axis2c .dll 文件创建了axis2c .a 文件。
- 我用 reimp 创建了 .def 文件
- 然后我修改了 .def 文件中的每个 stdcall 函数(我将“_name@ordinal”更改为“name”)
- 然后我使用 dlltool 创建 .a 文件。
我将 .a 文件链接到我的项目。一切顺利,我可以编译我的项目。但是当我尝试运行它时。我得到这个错误。
在动态链接库中找不到过程入口点 axiom_attribute_create
我已将我的项目包含在此链接中。
我用 MinGW 下载了一个 CodeBlocks。codeblocks-10.05mingw-setup.exe (我猜它使用MinGw32bit)。然后我按照@mikekinghan 所说的步骤设置Build Options。然后我建立了这个项目。我得到了这个错误。我已经将 Axis2c lib 文件夹添加到路径环境中。(我什至按照@mikekinghan 的建议将 axiom.dll 复制到“C:\Windows\SysWOW64”。
这是构建日志:
-------------- Build: Debug in Math ---------------
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\adb_addOperatorResponse.c -o obj\Debug\adb_addOperatorResponse.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from E:\dev\c\Math\adb_addOperatorResponse.h:21,
from E:\dev\c\Math\adb_addOperatorResponse.c:10:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:\dev\c\Math\adb_addOperatorResponse.c: In function 'adb_addOperatorResponse_serialize_obj':
E:\dev\c\Math\adb_addOperatorResponse.c:466: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
E:\dev\c\Math\adb_addOperatorResponse.c:374: warning: unused variable 'ns_already_defined'
E:\dev\c\Math\adb_addOperatorResponse.c:372: warning: unused variable 'qname_prefix'
E:\dev\c\Math\adb_addOperatorResponse.c:371: warning: unused variable 'qname_uri'
E:\dev\c\Math\adb_addOperatorResponse.c:367: warning: unused variable 'tag_closed'
E:\dev\c\Math\adb_addOperatorResponse.c: In function 'adb_addOperatorResponse_reset_addOperatorReturn':
E:\dev\c\Math\adb_addOperatorResponse.c:568: warning: unused variable 'element'
E:\dev\c\Math\adb_addOperatorResponse.c:567: warning: unused variable 'count'
E:\dev\c\Math\adb_addOperatorResponse.c:566: warning: unused variable 'i'
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\axis2_extension_mapper.c -o obj\Debug\axis2_extension_mapper.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from E:\dev\c\Math\axis2_extension_mapper.h:14,
from E:\dev\c\Math\axis2_extension_mapper.c:10:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:\dev\c\Math\axis2_extension_mapper.c: In function 'axis2_extension_mapper_type_from_node':
E:\dev\c\Math\axis2_extension_mapper.c:31: warning: unused variable 'element_qname'
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\axis2_stub_MathService.c -o obj\Debug\axis2_stub_MathService.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from C:\Tools\axis2c\include/neethi_includes.h:22,
from C:\Tools\axis2c\include/neethi_operator.h:29,
from C:\Tools\axis2c\include/neethi_policy.h:29,
from C:\Tools\axis2c\include/axis2_svc_client.h:56,
from C:\Tools\axis2c\include/axis2_stub.h:35,
from C:\Tools\axis2c\include/axis2_client.h:31,
from E:\dev\c\Math\axis2_stub_MathService.h:14,
from E:\dev\c\Math\axis2_stub_MathService.c:10:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:\dev\c\Math\axis2_stub_MathService.c: In function 'axis2_stub_populate_services_for_MathService':
E:\dev\c\Math\axis2_stub_MathService.c:72: warning: unused variable 'status'
E:\dev\c\Math\axis2_stub_MathService.c:71: warning: unused variable 'neethi_policy'
E:\dev\c\Math\axis2_stub_MathService.c:70: warning: unused variable 'policy_root_ele'
E:\dev\c\Math\axis2_stub_MathService.c:69: warning: unused variable 'policy_node'
E:\dev\c\Math\axis2_stub_MathService.c:68: warning: unused variable 'desc'
E:\dev\c\Math\axis2_stub_MathService.c:66: warning: unused variable 'policy_include'
E:\dev\c\Math\axis2_stub_MathService.c: In function 'axis2_stub_on_complete_MathService_addOperator':
E:\dev\c\Math\axis2_stub_MathService.c:277: warning: unused variable 'soap_fault'
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\main.c -o obj\Debug\main.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from C:\Tools\axis2c\include/neethi_includes.h:22,
from C:\Tools\axis2c\include/neethi_operator.h:29,
from C:\Tools\axis2c\include/neethi_policy.h:29,
from C:\Tools\axis2c\include/axis2_svc_client.h:56,
from C:\Tools\axis2c\include/axis2_stub.h:35,
from C:\Tools\axis2c\include/axis2_client.h:31,
from E:\dev\c\Math\axis2_stub_MathService.h:14,
from E:\dev\c\Math\main.c:1:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:\dev\c\Math\main.c:3: warning: second argument of 'main' should be 'char **'
E:\dev\c\Math\main.c: In function 'main':
E:\dev\c\Math\main.c:8: warning: unused variable 'operation'
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\adb_addOperator.c -o obj\Debug\adb_addOperator.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from E:\dev\c\Math\adb_addOperator.h:21,
from E:\dev\c\Math\adb_addOperator.c:10:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:\dev\c\Math\adb_addOperator.c: In function 'adb_addOperator_serialize_obj':
E:\dev\c\Math\adb_addOperator.c:574: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
E:\dev\c\Math\adb_addOperator.c:640: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
E:\dev\c\Math\adb_addOperator.c:480: warning: unused variable 'ns_already_defined'
E:\dev\c\Math\adb_addOperator.c:478: warning: unused variable 'qname_prefix'
E:\dev\c\Math\adb_addOperator.c:477: warning: unused variable 'qname_uri'
E:\dev\c\Math\adb_addOperator.c:473: warning: unused variable 'tag_closed'
E:\dev\c\Math\adb_addOperator.c: In function 'adb_addOperator_reset_num1':
E:\dev\c\Math\adb_addOperator.c:742: warning: unused variable 'element'
E:\dev\c\Math\adb_addOperator.c:741: warning: unused variable 'count'
E:\dev\c\Math\adb_addOperator.c:740: warning: unused variable 'i'
E:\dev\c\Math\adb_addOperator.c: In function 'adb_addOperator_reset_num2':
E:\dev\c\Math\adb_addOperator.c:848: warning: unused variable 'element'
E:\dev\c\Math\adb_addOperator.c:847: warning: unused variable 'count'
E:\dev\c\Math\adb_addOperator.c:846: warning: unused variable 'i'
mingw32-g++.exe -LC:\Tools\axis2c\include -LE:\dev\CodeBlocks\MinGW\lib -o bin\Debug\Math.exe obj\Debug\adb_addOperatorResponse.o obj\Debug\axis2_extension_mapper.o obj\Debug\axis2_stub_MathService.o obj\Debug\main.o obj\Debug\adb_addOperator.o -laxiom -laxutil -laxis2_engine -laxis2_parser
e:/dev/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe: cannot find -laxiom
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 6 seconds)
1 errors, 35 warnings
似乎我把 ../include 放在搜索目录>链接器中是错误的,我修复了这个错误。
我建立了项目,然后我得到了这个:
-------------- Build: Debug in Math ---------------
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\adb_addOperatorResponse.c -o obj\Debug\adb_addOperatorResponse.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from E:\dev\c\Math\adb_addOperatorResponse.h:21,
from E:\dev\c\Math\adb_addOperatorResponse.c:10:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:\dev\c\Math\adb_addOperatorResponse.c: In function 'adb_addOperatorResponse_serialize_obj':
E:\dev\c\Math\adb_addOperatorResponse.c:466: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\axis2_extension_mapper.c -o obj\Debug\axis2_extension_mapper.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from E:\dev\c\Math\axis2_extension_mapper.h:14,
from E:\dev\c\Math\axis2_extension_mapper.c:10:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\axis2_stub_MathService.c -o obj\Debug\axis2_stub_MathService.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from C:\Tools\axis2c\include/neethi_includes.h:22,
from C:\Tools\axis2c\include/neethi_operator.h:29,
from C:\Tools\axis2c\include/neethi_policy.h:29,
from C:\Tools\axis2c\include/axis2_svc_client.h:56,
from C:\Tools\axis2c\include/axis2_stub.h:35,
from C:\Tools\axis2c\include/axis2_client.h:31,
from E:\dev\c\Math\axis2_stub_MathService.h:14,
from E:\dev\c\Math\axis2_stub_MathService.c:10:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\main.c -o obj\Debug\main.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from C:\Tools\axis2c\include/neethi_includes.h:22,
from C:\Tools\axis2c\include/neethi_operator.h:29,
from C:\Tools\axis2c\include/neethi_policy.h:29,
from C:\Tools\axis2c\include/axis2_svc_client.h:56,
from C:\Tools\axis2c\include/axis2_stub.h:35,
from C:\Tools\axis2c\include/axis2_client.h:31,
from E:\dev\c\Math\axis2_stub_MathService.h:14,
from E:\dev\c\Math\main.c:1:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:\dev\c\Math\main.c:3: warning: second argument of 'main' should be 'char **'
mingw32-gcc.exe -Wall -g -IC:\Tools\axis2c\include -IE:\dev\CodeBlocks\MinGW -c E:\dev\c\Math\adb_addOperator.c -o obj\Debug\adb_addOperator.o
In file included from C:\Tools\axis2c\include/platforms/axutil_platform_auto_sense.h:40,
from C:\Tools\axis2c\include/axutil_dll_desc.h:31,
from C:\Tools\axis2c\include/axutil_class_loader.h:31,
from C:\Tools\axis2c\include/axis2_util.h:24,
from E:\dev\c\Math\adb_addOperator.h:21,
from E:\dev\c\Math\adb_addOperator.c:10:
C:\Tools\axis2c\include/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:\dev\c\Math\adb_addOperator.c: In function 'adb_addOperator_serialize_obj':
E:\dev\c\Math\adb_addOperator.c:574: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
E:\dev\c\Math\adb_addOperator.c:640: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
mingw32-g++.exe -LC:\Tools\axis2c\lib -LE:\dev\CodeBlocks\MinGW\lib -o bin\Debug\Math.exe obj\Debug\adb_addOperatorResponse.o obj\Debug\axis2_extension_mapper.o obj\Debug\axis2_stub_MathService.o obj\Debug\main.o obj\Debug\adb_addOperator.o -laxiom -laxutil -laxis2_engine -laxis2_parser
obj\Debug\adb_addOperatorResponse.o: In function `adb_addOperatorResponse_create':
E:/dev/c/Math/adb_addOperatorResponse.c:58: undefined reference to `_imp__axutil_error_set_error_number'
E:/dev/c/Math/adb_addOperatorResponse.c:58: undefined reference to `_imp__axutil_error_set_status_code'
E:/dev/c/Math/adb_addOperatorResponse.c:64: undefined reference to `_imp__axutil_strdup'
E:/dev/c/Math/adb_addOperatorResponse.c:67: undefined reference to `_imp__axutil_qname_create'
obj\Debug\adb_addOperatorResponse.o: In function `adb_addOperatorResponse_free_obj':
E:/dev/c/Math/adb_addOperatorResponse.c:139: undefined reference to `_imp__axutil_error_set_error_number'
E:/dev/c/Math/adb_addOperatorResponse.c:139: undefined reference to `_imp__axutil_error_set_status_code'
E:/dev/c/Math/adb_addOperatorResponse.c:139: undefined reference to `_imp__axutil_error_set_status_code'
E:/dev/c/Math/adb_addOperatorResponse.c:150: undefined reference to `_imp__axutil_qname_free'
obj\Debug\adb_addOperatorResponse.o: In function `adb_addOperatorResponse_deserialize_obj':
E:/dev/c/Math/adb_addOperatorResponse.c:209: undefined reference to `_imp__axutil_error_set_error_number'
E:/dev/c/Math/adb_addOperatorResponse.c:209: undefined reference to `_imp__axutil_error_set_status_code'
E:/dev/c/Math/adb_addOperatorResponse.c:209: undefined reference to `_imp__axutil_error_set_status_code'
E:/dev/c/Math/adb_addOperatorResponse.c:215: undefined reference to `_imp__axiom_node_get_next_sibling'
E:/dev/c/Math/adb_addOperatorResponse.c:213: undefined reference to `_imp__axiom_node_get_node_type'
E:/dev/c/Math/adb_addOperatorResponse.c:227: undefined reference to `_imp__axiom_node_get_data_element'
E:/dev/c/Math/adb_addOperatorResponse.c:228: undefined reference to `_imp__axiom_element_get_qname'
E:/dev/c/Math/adb_addOperatorResponse.c:229: undefined reference to `_imp__axutil_qname_equals'
E:/dev/c/Math/adb_addOperatorResponse.c:232: undefined reference to `_imp__axiom_node_get_first_child'
E:/dev/c/Math/adb_addOperatorResponse.c:237: undefined reference to `_imp__axutil_qname_to_string'
E:/dev/c/Math/adb_addOperatorResponse.c:237: undefined reference to `_imp__axutil_qname_to_string'
E:/dev/c/Math/adb_addOperatorResponse.c:260: undefined reference to `_imp__axiom_node_get_next_sibling'
E:/dev/c/Math/adb_addOperatorResponse.c:258: undefined reference to `_imp__axiom_node_get_node_type'
E:/dev/c/Math/adb_addOperatorResponse.c:264: undefined reference to `_imp__axiom_node_get_data_element'
E:/dev/c/Math/adb_addOperatorResponse.c:265: undefined reference to `_imp__axiom_element_get_qname'
E:/dev/c/Math/adb_addOperatorResponse.c:268: undefined reference to `_imp__axutil_qname_create'
E:/dev/c/Math/adb_addOperatorResponse.c:272: undefined reference to `_imp__axutil_qname_equals'
E:/dev/c/Math/adb_addOperatorResponse.c:274: undefined reference to `_imp__axutil_qname_equals'
E:/dev/c/Math/adb_addOperatorResponse.c:280: undefined reference to `_imp__axiom_element_get_text'
E:/dev/c/Math/adb_addOperatorResponse.c:298: undefined reference to `_imp__axutil_qname_free'
E:/dev/c/Math/adb_addOperatorResponse.c:308: undefined reference to `_imp__axutil_qname_free'
E:/dev/c/Math/adb_addOperatorResponse.c:317: undefined reference to `_imp__axutil_qname_free'
obj\Debug\adb_addOperatorResponse.o: In function `adb_addOperatorResponse_serialize_obj':
E:/dev/c/Math/adb_addOperatorResponse.c:392: undefined reference to `_imp__axutil_error_set_error_number'
E:/dev/c/Math/adb_addOperatorResponse.c:392: undefined reference to `_imp__axutil_error_set_status_code'
E:/dev/c/Math/adb_addOperatorResponse.c:392: undefined reference to `_imp__axutil_error_set_status_code'
E:/dev/c/Math/adb_addOperatorResponse.c:395: undefined reference to `_imp__axutil_hash_make'
E:/dev/c/Math/adb_addOperatorResponse.c:398: undefined reference to `_imp__axiom_namespace_create'
E:/dev/c/Math/adb_addOperatorResponse.c:401: undefined reference to `_imp__axutil_strdup'
E:/dev/c/Math/adb_addOperatorResponse.c:401: undefined reference to `_imp__axutil_hash_set'
E:/dev/c/Math/adb_addOperatorResponse.c:404: undefined reference to `_imp__axiom_element_create'
E:/dev/c/Math/adb_addOperatorResponse.c:407: undefined reference to `_imp__axiom_element_set_namespace'
E:/dev/c/Math/adb_addOperatorResponse.c:411: undefined reference to `_imp__axiom_data_source_create'
E:/dev/c/Math/adb_addOperatorResponse.c:412: undefined reference to `_imp__axiom_data_source_get_stream'
E:/dev/c/Math/adb_addOperatorResponse.c:414: undefined reference to `_imp__axutil_hash_get'
E:/dev/c/Math/adb_addOperatorResponse.c:418: undefined reference to `_imp__axutil_hash_set'
E:/dev/c/Math/adb_addOperatorResponse.c:420: undefined reference to `_imp__axiom_namespace_create'
E:/dev/c/Math/adb_addOperatorResponse.c:420: undefined reference to `_imp__axiom_element_declare_namespace_assume_param_ownership'
E:/dev/c/Math/adb_addOperatorResponse.c:436: undefined reference to `_imp__axutil_strlen'
E:/dev/c/Math/adb_addOperatorResponse.c:436: undefined reference to `_imp__axutil_strlen'
E:/dev/c/Math/adb_addOperatorResponse.c:441: undefined reference to `_imp__axutil_strlen'
E:/dev/c/Math/adb_addOperatorResponse.c:441: undefined reference to `_imp__axutil_strlen'
E:/dev/c/Math/adb_addOperatorResponse.c:458: undefined reference to `_imp__axutil_strcmp'
Process terminated with status 1 (0 minutes, 9 seconds)
50 errors, 9 warnings
形成@MikeKinghan 试图教我的内容,我现在理解了链接器命令的含义,并且我看到这次链接器设置正确。但为什么它不能正确编译?