[英]Error: "The procedure entry point ?JPEG_convert_to_rgb@@YAPAEHPAEPAH1@Z could not be located in the dynamic link library libimage.dll"
[英]The procedure entry point axiom_attribute_create could not be located in the dynamic link library
我在c中有一個項目,我想用MinGW在CodeBlocks中編譯它。 我試圖鏈接其所需的庫,但我得到了
未定義的引用錯誤
所以我搜索並發現我使用的庫是用MVC ++編譯的,不能和MinGW一起使用。 (我不是c的專家,所以我有點困惑。)我找到了這個鏈接並做了他們所說的,以解決我的問題。
我從原來的axis2c .dll文件創建了axis2c .a文件。
我將.a文件鏈接到我的項目。 一切都很順利,我可以編譯我的項目。 但是當我試圖運行它。 我收到這個錯誤。
無法在動態鏈接庫中找到過程入口點axiom_attribute_create
我已將此項目包含在此鏈接中 。
我用MinGW下載了一個CodeBlocks。 codeblocks-10.05mingw-setup.exe(我想使用MinGw32bit )。然后我按照@mikekinghan所說的設置構建選項的步驟。 然后我建立了這個項目。 我收到了這個錯誤。 我已經將Axis2c lib文件夾添加到路徑環境中。 (我甚至將axiom.dll復制到了“C:\\ Windows \\ SysWOW64”,正如@mikekinghan建議的那樣。
這是構建日志:
-------------- 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試圖教我的東西,我現在理解了Linker命令的含義,我看到這次Linker設置正確。 但為什么不能正確編譯?
我不遵循你采取的步驟背后的原因,也沒有關於你所做的具體數據,所以這是“從第一原則”的回答。
如果要使用Microsoft的鏈接器(您沒有這樣做)將DLL foo.dll
與您的程序鏈接,則無法將foo.dll
直接傳遞給鏈接器。 如您所知,您必須傳遞一個導入庫foo.lib
,它是一個小的靜態庫“stubs”,表示由foo.dll
導出的foo.dll
。 在運行時,程序加載程序掃描這些存根,並且(如果可能)用匹配的引用替換它們,它通過根據Windows DLL搜索路徑搜索可用的DLL找到它們找到的導出函數
如果你想使用MinGW GNU鏈接器(你正在做)將foo.dll
與你的程序鏈接,則不需要導入庫foo.lib
。 此鏈接器可以直接鏈接foo.dll
。 你沒有理由不這樣做。
要使用MinGW GNU鏈接器直接將foo.dll
鏈接到您的程序,鏈接器當然必須能夠通過其遵循的規則在鏈接時找到foo.dll
來查找庫,無論是靜態還是動態。 就像微軟的鏈接器一樣,DLL的成功鏈接並不能保證程序加載器在運行時也能找到DLL。 程序加載程序根據Windows DLL搜索路徑搜索DLL:它不知道或關心您用於鏈接程序的鏈接器。 您必須確保鏈接器在鏈接時找到DLL,然后您需要確保程序加載器將在運行時找到它。
你怎么告訴MinGW鏈接器直接鏈接foo.dll
? 您只需遵循將庫傳遞給鏈接器的規則,如此處所述 。
但在你可以嘗試之前還有一個必須滿足的基本條件。 您不能將32位DLL與64位程序鏈接,反之亦然 。 你說你正在用64位MinGW構建; 因此默認情況下它將構建64位可執行文件,如果您正在構建64位.exe
則必須將其與64位版本的axis2c
DLL鏈接。
我不知道你的axis2c
庫在哪里,但如果你下載了Apache的v1.6.0二進制存檔,那么你就有了32位的DLL。
您可以告訴您的64位MinGW構建一個32位.exe
,但您可能更喜歡將其與64位axis2c
DLL鏈接。 幸運的是,Google提供了64位版本。 從這里下載。 64位存檔是x86_64-wsdk7.1-r7acae470da50.7z 。 在方便的地方下載; 用7-Zip
提取它,然后我建議你將提取的文件夾重命名為能夠清楚識別它的東西,比如axis2c-x86_64-google
。
現在,我將在命令提示符下編譯並鏈接一個示例axis2c
程序,遵循鏈接器查找庫的規則。 我將構建的程序是Apache軟件包中提供的示例程序之一: axis2c-bin-1.6.0-win32\\samples\\src\\client\\echo
。 我隨機選擇它:它只包含一個源文件,即echo.c
我的工具鏈是64位GCC 4.9.2。 我下載了64位axis2c
軟件包,解壓縮axis2c
命名為C:\\develop\\stackoverflow\\axis2c-x86_64-google
我在echo
目錄中打開命令提示符並輸入:
gcc -IC:\develop\stackoverflow\axis2c-x86_64-google\include\axis2-1.6.0 -c echo.c -o echo.o
我告訴gcc
將echo.c
編譯為echo.o
,它應該在C:\\develop\\stackoverflow\\axis2c-x86_64-google\\include\\axis2-1.6.0
搜索非標准頭文件。 (要基本了解如何使用GCC編譯和鏈接程序,我建議你閱讀本教程 )。
我收到編譯器警告:
警告請在windows.h之前包含winsock2.h
但這不是一個錯誤所以我不會為了這個演示的目的而擔心它。
接下來,我想鏈接echo.o
我剛剛使用axis2c
DLL構建了一個名為axis2c-echo.exe
的程序。 所以我輸入:
gcc -o axis2c-echo.exe echo.o -LC:\develop\stackoverflow\axis2c-x86_64-google\lib -laxiom -laxutil -laxis2_engine -laxis2_parser
我告訴gcc
除了目標文件echo.o
之外,程序還需要鏈接庫( -l
) axiom
, axutil
, axis2_engine
和axis2_parser
,並且鏈接器應該在C:\\develop\\stackoverflow\\axis2c-x86_64-google\\lib
查找非標准庫C:\\develop\\stackoverflow\\axis2c-x86_64-google\\lib
。
請注意,我不需要告訴鏈接器,例如, axiom
庫是axiom.dll
而不是axiom.lib
或libaxiom.a
。 -laxiom
告訴鏈接器在給定的搜索目錄中查找任何這些內容,如果它找到動態庫( axiom.dll
),它會更喜歡它到任何靜態庫axiom.lib
或libaxiom.a
。 在C:\\develop\\stackoverflow\\axis2c-x86_64-google\\lib
它實際上會找到axiom.dll
和axiom.lib
,並且更喜歡前者; 但你不需要關心。
聯動命令成功,所以現在我有一個程序, axis2c-echo.exe
在同一目錄下。 我會運行它:
axis2c-echo
但我不能。 我剛剛得到一個Windows錯誤對話框,上面寫着:
此程序無法啟動,因為您的計算機缺少axiom.dll。 嘗試重新安裝該程序以修復此錯誤。
問題是axiom.dll
是從C:\\develop\\stackoverflow\\axis2c-x86_64-google\\lib
,這不是程序加載程序在運行時搜索DLL的地方之一。
現在如果我計划在我的計算機上定期運行axis2c
程序,我會通過在C:\\Windows\\SysWOW64
安裝64位axis2c
DLL來解決這個問題,因為64位Windows總是在那里搜索DLL。 但我不打算這樣做,所以我只是暫時將C:\\develop\\stackoverflow\\axis2c-x86_64-google\\lib
到Windows DLL搜索路徑。 Windows DLL搜索路徑的最后一站是: PATH環境變量中列出的目錄 。 所以在我的命令提示符下,我將輸入:
set PATH=%PATH%;C:\develop\stackoverflow\axis2c-x86_64-google\lib
然后再次運行axis2c-echo
。 這次,輸出是:
AXIS2C_HOME未設置 - 寫入日志。 dir使用端點: http:// localhost:9090 / axis2 / services / echo創建服務客戶端時出錯,請再次檢查AXIS2C_HOME
現在程序本身就在抱怨,但這對我來說已經足夠了! 它已編譯,鏈接,加載,生成一些輸出並優雅地完成。
現在可能很明顯你如何設置Code :: Blocks項目來構建同一個程序:
echo
目錄中創建一個C語言控制台項目。 main.c
源文件 echo.c
添加到項目中。 C:\\develop\\stackoverflow\\axis2c-x86_64-google\\include\\axis2-1.6.0
(或path\\to\\your\\axis2c-1.6.0\\header-files
) C:\\develop\\stackoverflow\\axis2c-x86_64-google\\lib
(或path\\to\\your\\axis2c-1.6.0\\libraries
) -laxiom -laxutil -laxis2_engine -laxis2_parser
這不是您在C :: B中成功配置此項目的唯一方法,但它對應於某人通常在命令提示符下構建項目的方式,並且意味着C :: B執行的工具鏈命令將是簡潔而正常。
如果按照以下步驟構建示例echo
項目,則成功配置自己的項目應該沒有太大困難。
您的項目包含5個源文件,每個文件都必須成功編譯,然后所有需要鏈接在一起,以及一些axis2c
DLL,以構建您的程序。
我們來看看你的構建日志。
每個5個源文件都有一個編譯命令:
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
...
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
...
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
...
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
...
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
...
然后有一個鏈接命令:
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
...
將這些命令復制/粘貼到您可以從頭到尾查看它們的位置。
在我放置'...'的所有地方,編譯器或鏈接器都對你的程序提出了一些抱怨。
5編譯命令發出的所有診斷都是警告 。 無論什么是不對的,它實際上並沒有阻止編譯器將源文件( .c
)編譯成目標文件( .o
)。 如果任何.c
文件中存在任何編譯錯誤 ,那么編譯器將無法創建.o
文件,並且構建將在不嘗試鏈接程序的情況下停止,因為在缺少某些目標文件時將其鏈接會是徒勞的。
這並不意味着你不必理會編譯器警告。 他們可能會警告您的程序中可能存在的錯誤 , 其中一些是錯誤的 。 所以你需要修復它們。
鏈接命令失敗 。 你沒有程序,這是你的首要問題。
為了理解編譯器和鏈接器診斷,並且能夠自己修復它們,您需要了解編譯器和鏈接器命令的含義。
我們可以看到工具鏈Code :: Blocks正在驅動你的是MinGW項目的32位Windows GCC端口(GNU編譯器集合) 。 GCC是C / C ++編程工具鏈的老手:它支持每個操作系統和每個處理器; 它用於每個應用領域。 它完全獨立於您可以驅動它的眾多IDE中的所有IDE,並且所有這些IDE(Eclipse,Code :: Blocks,KDevelop,CodeLite,Anjuta,Dev-C ++等)都以隱含的假設來到您的身邊您了解編譯和鏈接GCC。 至少,它們都不能讓你不必理解編譯和鏈接GCC。
在繼續之前,所有這一切的生命教訓將是: 將你的IDE拉開一段時間。 了解如何使用GCC構建程序。 然后很明顯如何使用IDE來完成它。
所有編譯命令都由mingw32-gcc.exe
執行。 那是GCC工具驅動程序,它的C編譯器 “姿勢”。 如果你查看它安裝的目錄,也許是C:\\MinGW\\bin
,你還會看到程序gcc.exe
, g++.exe
,加上那兩個前綴為mingw32-
。 所有這些程序都是GCC工具驅動程序,具有適應不同角色的不同“姿勢”。
您的鏈接命令由mingw32-g++.exe
。 這是GCC工具驅動程序,在其C ++鏈接器 “姿勢”中再次出現。 Code :: Blocks默認情況下將C ++鏈接器配置為鏈接C程序,這似乎令人費解。 這樣做是因為C ++鏈接適用於所有C,所有C ++或兩者的混合的程序。 但C鏈接不適用於C ++程序。
無論名稱是什么“姿勢”,GCC工具驅動程序都會通過檢查命令行上的選項以及傳遞給它的文件的文件擴展名來確定需要做什么。 因此它嘗試將每個.c
源文件編譯為C, 因為它們是.c
文件。 如果它們是.cpp
文件,那么它會嘗試將它們編譯為C ++。 一旦確定它做了什么,它就會將工作委托給適當的專用工具--C編譯器,C ++編譯器,匯編器,鏈接器。
以下是每個編譯命令的含義:
-Wall
=>啟用所有警告 -g
=>在目標文件中生成調試信息。 -IC:\\Tools\\axis2c\\include
=>在C:\\Tools\\axis2c\\include
搜索非標准頭文件 -IE:\\dev\\CodeBlocks\\MinGW
=>還在E:\\dev\\CodeBlocks\\MinGW
搜索非標准頭文件 -c
=>只需編譯; 不要鏈接 E:\\dev\\c\\Math\\some_filename.c
=>編譯此文件。 -o obj\\Debug\\some_filename.o
=>輸出目標文件obj\\Debug\\some_filename.o
這是你的鏈接命令的含義:
-LC:\\Tools\\axis2c\\include
=>在C:\\Tools\\axis2c\\include
搜索非標准庫( .lib
, .a
, .dll
) -LE:\\dev\\CodeBlocks\\MinGW\\lib
=>還在E:\\dev\\CodeBlocks\\MinGW\\lib
搜索非標准庫 -o bin\\Debug\\Math.exe
=>輸出可執行文件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
=>鏈接libary axiom.dll
或者失敗, axiom.lib
或libaxiom.a
,無論它在指定的鏈接器搜索目錄( -L
)中首次找到它,還是在鏈接器的標准目錄中失敗。 -laxutil
=>鏈接libary axutil.dll
或者失敗, axutil.lib
或libaxutil.a
等... -laxis2_engine
=>鏈接libary axis2_engine.dll
或者失敗,即axis2_engine.lib
或libaxis2_engine.a
等... -laxis2_parser
=>鏈接libary axis2_parser.dll
或者失敗,即axis2_parser.lib
或libaaxis2_parser.a
等... 您可能想知道工具驅動程序如何知道鏈接命令是鏈接命令,而不是C ++編譯命令? 它知道沒有編譯要做,因為沒有輸入文件可以編譯 。 它們都是目標文件( .o
)。 並且它知道它應該鏈接它們,因為它沒有被告知不要鏈接它們: -c
選項不存在。
您的鏈接失敗,因為:
e:/dev/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe: cannot find -laxiom
ld.exe
是鏈接器本身:GCC工具驅動程序在完成鏈接時調用的專用工具。 它無法在您指定的任何鏈接器搜索目錄( -L
)中找到您的axiom
庫,當然也不能在任何標准搜索目錄中找到。
現在您已了解鏈接命令的含義,您可以輕松查看錯誤。 您指定的鏈接器搜索目錄是:
C:\Tools\axis2c\include
E:\dev\CodeBlocks\MinGW\lib
和你的axis2c
庫( axiom.dll
等)不在這兩個地方。 C:\\Tools\\axis2c\\include
與您告訴編譯器搜索axis2c
頭文件的位置相同 :您有:
-IC:\Tools\axis2c\include
因此,如果這是axis2c
頭文件的位置,那么我想這些庫位於C:\\Tools\\axis2c\\lib
。 看一看。 假設是正確的,那么在C :: B IDE中,您需要從項目的搜索目錄 - > 鏈接器中刪除錯誤的C:\\Tools\\axis2c\\include
,並將其替換為正確的C:\\Tools\\axis2c\\lib
C:\\Tools\\axis2c\\include
在搜索目錄 - > 編譯器中 ,因為這是正確的。
繼續OP的進一步問題
我相信你的axis2c
庫和頭文件來自於存檔axis2c-bin-1.6.0-win32.zip
Apache的Axis2 / C下載頁面 。
此版本的頭文件中存在一個錯誤 ,導致您在MinGW32工具鏈中看到的鏈接錯誤。
這個錯誤不影響谷歌在我對這個問題的第一個回答中提到你的Axis2 / C版本 。 那時你說你正在使用64位MinGW進行構建,但是后來很明顯你正在構建32位MinGW。 在這種情況下,您應該下載Google的32位版本Axis2 / C.
使用7-Zip解壓縮存檔,並將解壓縮的文件夾從axis2c
重命名為axis2c-x86-google
,以清楚它是什么,然后將其復制到方便開發的地方。 假設你把它放在C:\\Tools\\axis2c-x86-google
。
然后在C :: B IDE中,在搜索目錄 - > 編譯器中 ,更改:
C:\Tools\axis2c\include
至:
C:\Tools\axis2c-x86-google\include\axis2-1.6.0
並在搜索目錄 - > 鏈接器中 ,更改:
C:\Tools\axis2c\lib
至:
C:\Tools\axis2c-x86-google\lib
這就是所謂的庫axiom.dll
在Apache的版本被稱為axis2_axiom.dll
在谷歌的釋放。 因此,在鏈接器設置 - > 其他鏈接器選項中 ,更改:
-laxiom
至:
-laxis2_axiom
然后你的程序成功鏈接(對我來說)。
繼續
根據您的意見,程序現在無法在運行時加載錯誤:
The procedure entry point axis2_callback_create could not be located in the dynamic link library
這意味着在運行時找不到提供axis2_callback_create
的正確DLL。
你說:
我還在路徑環境中添加了“lib”。 並將lib dll文件添加到“C:\\ Windows \\ SysWOW64”
PATH
所做的操作,它可能沒有任何效果。
PATH
環境變量來執行此操作,那么這對您嘗試運行程序的已打開的shell沒有任何影響。 您需要保存高級系統設置,然后再次嘗試在新shell中運行程序。 我可以通過以下所有方式啟動程序而不會出現DLL錯誤:
C:\\Tools\\axis2c-x86-google\\lib\\*.dll
與Math.exe
位於同一目錄Math.exe
C:\\Tools\\axis2c-x86-google\\lib\\*.dll
位於C:Windows\\SysWOW64
set PATH=%PATH%;C:\\path\\to\\my\\axis2c-x86-google\\lib
C:\\path\\to\\my\\axis2c-x86-google\\lib
添加C:\\path\\to\\my\\axis2c-x86-google\\lib
到PATH
環境變量之后的新shell中。 如果它們都不適合你,那我恐怕問題超出了我:(
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.