The procedure entry point axiom_attribute_create could not be located in the dynamic link library

我只是一个虾纸丫 提交于 2019-12-12 01:46:31

问题


I have a project in c and I want to compile it in CodeBlocks with MinGW. I tried to link its needed libraries but I got

undefined reference error

so I searched and found out that the libraries that I was using was compiled with MVC++ and cannot be used with MinGW. (I am not an expert in c, so I'm a little bit confused.) I found This link and did what they said in order to solve my problem.

I have created axis2c .a files from the original axis2c .dll files.

  • I created .def files with reimp
  • then I modified each stdcall function in .def files (I changed "_name@ordinal" to "name")
  • then I used dlltool to create .a files.

I linked the .a files to my project. Everything went fine and I could compile my project. but when I try to run it. I get this error.

The procedure entry point axiom_attribute_create could not be located in the dynamic link library

I have included my project in this Link.

I downloaded a CodeBlocks with MinGW. codeblocks-10.05mingw-setup.exe (which I guess uses MinGw32bit).Then I followed the steps that @mikekinghan said to set up Build Options. Then I built the project. I got this error. I have already added Axis2c lib folder to path Environment. (I even copied axiom.dll to "C:\Windows\SysWOW64" as @mikekinghan suggested.

Here is the build log :

-------------- 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

It seems that I made a mistake putting ../include in Search Directories>Linker I fixed that mistake.

I build the project then I get this :

-------------- 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

Form what @MikeKinghan tried to teach me, I understand the meaning of Linker commands now, and I see that the Linker is set correctly this time. but why can't it compile properly?


回答1:


Your project contains 5 source files, which each has to be successfully compiled, and then all need linked together, along with some axis2c DLLs, to build your program.

Let's look at your build log.

There is a compile command for each of the 5 source files:

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
...

and then there is a link command:

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
...

Copy/paste these commands out somewhere where you can see them from end to end.

In all of the places where I have put '...', the compiler or linker has emitted some complaint about your program.

All of the diagnostics emitted by the 5 compile commands are warnings. Whatever is not right, it doesn't actually stop the compiler from compiling the source file (.c) into an object file (.o). If there had been any compilation errors in any .c file, then the compiler would not have been able to create the .o file, and the build would have stopped without attempting to link the program, because linking it when some object files are missing would be futile.

This does not mean you don't have to bother about the compiler warnings. They might be warnings about possible bugs in your program, and some of them are. So you'll need to fix them.

The link command has failed. You have no program, which is your top problem.

In order to make sense of compiler and linker diagnostics, and be able to fix them yourself, you need to understand what the compiler and linker commands mean.

We can see that the toolchain Code::Blocks is driving for you is the MinGW project's 32-bit Windows port of GCC (The GNU Compiler Collection). GCC is the daddy of C/C++ programming toolchains: it's supported for every operating system and every processor; it's used in every application domain. It's completely independent of any of the numerous IDEs that you can get to drive it, and all of those IDEs (Eclipse, Code::Blocks, KDevelop, CodeLite, Anjuta, Dev-C++, etc.) come to you with the implicit assumption that you understand compiling and linking with GCC. At least, none of them can save you from having to understand compiling and linking with GCC.

Before going any further then, the life-lesson of all this is going to be: Kick away your IDE for a while. Learn about building programs with GCC, itself. Then it will be obvious how to do it with your IDE.

All of your compile commands are executed by mingw32-gcc.exe. That's the GCC tool-driver, in its C compiler "posture". If you look in the directory where it's installed, maybe C:\MinGW\bin, you'll see also programs gcc.exe, g++.exe, plus those two with the prefix mingw32-. All of these programs are the GCC tool driver, in different "postures" adapted to different roles.

Your link command is executed by mingw32-g++.exe. That's the GCC tool-driver again, in its C++ linker "posture". It may seem puzzling that Code::Blocks by default configures the C++ linker to link C programs. It does that because C++ linkage works for programs that are all C, all C++, or a mixture of the two. But C linkage won't work for C++ programs.

Whatever "posture" is suggested by the name, the GCC tool driver figures out what needs to be done by inspecting the options on its commandline and the file extensions of the files that are passed to it. So it tries to compile each of your .c source files as C because they are .c files. If they were .cpp files then it would try to compile them as C++. Once it figures out what it do, it delegates the work to an appropriate specialized tool - C compiler, C++ compiler, assembler, linker.

Here's what each of your compile commands means:

  • -Wall => Enable all warnings
  • -g => Generate debugging information in the object file.
  • -IC:\Tools\axis2c\include => Search for non-standard header files in C:\Tools\axis2c\include
  • -IE:\dev\CodeBlocks\MinGW => Also search for non-standard header files in E:\dev\CodeBlocks\MinGW
  • -c => Just compile; don't link
  • E:\dev\c\Math\some_filename.c => Compile this file.
  • -o obj\Debug\some_filename.o => Output the object file obj\Debug\some_filename.o

And here's what your link command means:

  • -LC:\Tools\axis2c\include => Search for non-standard libraries (.lib, .a, .dll) in C:\Tools\axis2c\include
  • -LE:\dev\CodeBlocks\MinGW\lib => Also search for non-standard libraries in E:\dev\CodeBlocks\MinGW\lib
  • -o bin\Debug\Math.exe => Output the executable bin\Debug\Math.exe
  • obj\Debug\adb_addOperatorResponse.o => Link this object file
  • obj\Debug\axis2_extension_mapper.o => Also link this object file
  • obj\Debug\axis2_stub_MathService.o => Also link this object file
  • obj\Debug\main.o => Also link this object file
  • obj\Debug\adb_addOperator.o => Also link this object file
  • -laxiom => Link the libary axiom.dll or failing that, axiom.lib or libaxiom.a, wherever it is first found in the specified linker search directories (-L), or failing that in the linker's standard directories.
  • -laxutil => Link the libary axutil.dll or failing that, axutil.lib or libaxutil.a, etc...
  • -laxis2_engine => Link the libary axis2_engine.dll or failing that, axis2_engine.lib or libaxis2_engine.a, etc...
  • -laxis2_parser => Link the libary axis2_parser.dll or failing that, axis2_parser.lib or libaaxis2_parser.a, etc...

You might wonder how the tool-driver knows that the link command is a link command, and not perhaps a C++ compile command? It knows there is no compiling to do because none of the input files can be compiled. They are all object files (.o). And it knows it is supposed to link them because it hasn't been told not to link them: the -c option is absent.

You linkage failed because:

e:/dev/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe: cannot find -laxiom

ld.exe is the linker itself: the specialized tool that the GCC tool driver invokes when there is linking to be done. It can't find your axiom library in any of the linker search directories you specified (-L), nor, of course, in any of the standard search directories.

Now that you understand the meaning of your link command, it will be easy for you to see what's wrong. The linker search directories that you specified are:

C:\Tools\axis2c\include
E:\dev\CodeBlocks\MinGW\lib

and your axis2c libraries (axiom.dll etc) aren't in either of those places. C:\Tools\axis2c\include is the same place where you told the compiler to search for the axis2c header files: you have:

-IC:\Tools\axis2c\include

So if that's where the axis2c header files are, then the libraries, I guess, are in C:\Tools\axis2c\lib. Have a look. Assuming that's right, then in the C::B IDE you need to delete the wrong C:\Tools\axis2c\include from Search directories -> Linker for your project and replace it with the correct C:\Tools\axis2c\lib Leave C:\Tools\axis2c\include in Search directories -> Compiler, because that is correct.

Continued for OP's further issues

I believe that your axis2c libraries and header files originated from Apache's Axis2/C download page from the archive axis2c-bin-1.6.0-win32.zip.

This release suffers from a bug in its header files that causes the linkage errors you are seeing with the MinGW32 toolchain.

This bug does not affect Google's release of Axis2/C that I referred you to in my first answer to this question. At that time you said that you were building with 64-bit MinGW, but it has since become clear that you are building with 32-bit MinGW. In that case, you should download Google's 32-bit build Axis2/C

Unzip the archive with 7-Zip and rename the unzipped folder from axis2c to axis2c-x86-google, to make clear what it is, then copy it somewhere convenient for your development. Let's say you put it at C:\Tools\axis2c-x86-google.

Then in the C::B IDE, in Search directories -> Compiler, change:

C:\Tools\axis2c\include

to:

C:\Tools\axis2c-x86-google\include\axis2-1.6.0

and in Search directories -> Linker, change:

C:\Tools\axis2c\lib

to:

C:\Tools\axis2c-x86-google\lib

The library that is called axiom.dll in the Apache release is called axis2_axiom.dll in Google's release. Therefore in your Linker settings -> Other linker options, change:

-laxiom

to:

-laxis2_axiom

Your program then links successfully (for me).

Continued again

Per your comments, the program now fails to load at runtime with the error:

The procedure entry point axis2_callback_create could not be located in the dynamic link library

This means the correct DLL providing axis2_callback_create is not found at runtime.

You say:

I also added the "lib" to path environment. and also added the lib dll files to "C:\Windows\SysWOW64"

  • Do one or the other, not both.
  • Depending on what you did to add the Axis2/C library directory to the PATH, it may have had no effect.
    • If you did this in a shell (command prompt) window that was not the very same one in which your tried to run your program, then it will have had no effect, since environment settings that you make in a shell apply only to processes launched in the same shell.
    • If you did this by modifying the PATH environment variable in Advanced System Settings then that will have no effect on a shell already open in which you tried to run your program. You would need save the Advanced System Settings and then try again to run your program in a new shell.

I am able to start your program without DLL errors in all of the following ways:

  • With all of the files C:\Tools\axis2c-x86-google\lib\*.dll located in the same directory with Math.exe
  • With all of the files C:\Tools\axis2c-x86-google\lib\*.dll located instead in C:Windows\SysWOW64
  • In a shell window in which I have previously run: set PATH=%PATH%;C:\path\to\my\axis2c-x86-google\lib
  • In a new shell after I have added C:\path\to\my\axis2c-x86-google\lib to the PATH environment variable in Advanced System Settings.

If none of them works for you then I'm afraid the problem is beyond me :(




回答2:


I don't follow the reasoning behind the steps you have taken and don't have any concrete data about what you did, so this is an answer "from first principles".

If you want to link a DLL foo.dll with your program using Microsoft's linker (which you are not doing) you cannot pass foo.dll directly to the linker. As you know, you must instead pass an import library, foo.lib, which is a small static library of "stubs" representing the functions that are exported by foo.dll. At runtime, the program loader scans these stubs and (if possible) replaces them with matching references to to exported functions that it finds by searching available DLLs according to the Windows DLL Search Path

If you want to link foo.dll with your program using the MinGW GNU linker (which you are doing), no import library foo.lib is necessary. This linker can link foo.dll directly. There is no reason for you to do otherwise.

To link foo.dll directly with your program using the MinGW GNU linker, the linker, of course, must be able to find foo.dll at linktime by the the rules that it follows to find libraries, whether static or dynamic. And just as with Microsoft's linker, successful linkage of a DLL does not guarantee that the DLL will also be found at runtime by the program loader. The program loader searches for DLLs according to the the Windows DLL Search Path: it doesn't know or care which linker you used to link your program. You have to make sure that the linker finds the DLL at linktime, and then you need to make sure that the program loader will find it at runtime.

How do you tell the MinGW linker to link foo.dll directly? You just follow the rules for passing libraries to the linker, as documented here.

But before you can attempt that there is one other basic condition that has to be satisfied. You can't link a 32-bit DLL with a 64-bit program, or vice versa. You say you are building with 64-bit MinGW; so by default it will build 64-bit executables, and if your are building a 64-bit .exe then you must link it with 64-bit builds of the axis2c DLLs.

I don't know where you got your axis2c libraries, but if you downloaded Apache's v1.6.0 binary archive then you have got 32-bit DLLs.

You could tell your 64-bit MinGW to build a 32-bit .exe, but you'd probably prefer to link it with 64-bit axis2c DLLs. Fortunately, a 64-bit build is provided by Google. Download it from here. The 64-bit archive is x86_64-wsdk7.1-r7acae470da50.7z. Download it somewhere convenient; extract it with 7-Zip, and then I suggest you rename the extracted folder to something that will identify it clearly, like axis2c-x86_64-google.

Now, I'll compile and link at the command prompt an example axis2c program, following the linker's rules for finding libraries. The program I'll build is one of the sample programs provided in the Apache package: axis2c-bin-1.6.0-win32\samples\src\client\echo. I picked it at random: it contains only one source file, which is echo.c. My toolchain is 64-bit GCC 4.9.2. I have my 64-bit axis2c package downloaded, unzipped and renamed as C:\develop\stackoverflow\axis2c-x86_64-google

I open a command prompt in the echo directory and enter:

gcc -IC:\develop\stackoverflow\axis2c-x86_64-google\include\axis2-1.6.0 -c echo.c -o echo.o

I'm telling gcc to compile echo.c to echo.o, and that it should search for non-standard header files in C:\develop\stackoverflow\axis2c-x86_64-google\include\axis2-1.6.0. (To understand basically how to compile and link programs with GCC, I suggest you read this tutorial).

I get a compiler warning:

warning Please include winsock2.h before windows.h

but it's not an error so I'm not going to worry about it for the purposes of this demonstration.

Next, I want to link the echo.o I've just built with the axis2c DLLs that it requires to make a program called axis2c-echo.exe. So I enter:

gcc -o axis2c-echo.exe echo.o  -LC:\develop\stackoverflow\axis2c-x86_64-google\lib  -laxiom -laxutil -laxis2_engine -laxis2_parser

I'm telling gcc that besides the object file echo.o, the program needs to link the libraries (-l) axiom, axutil, axis2_engine and axis2_parser, and that the linker should look for non-standard libraries in C:\develop\stackoverflow\axis2c-x86_64-google\lib.

Notice that I don't need to tell the linker that, say, the axiom library is axiom.dll and not axiom.lib or libaxiom.a. -laxiom tells the linker to look for any of these in a given search directory and if it happens to finds a dynamic library (axiom.dll) it will prefer it to any static library axiom.lib or libaxiom.a. In C:\develop\stackoverflow\axis2c-x86_64-google\lib it will in fact find both axiom.dll and axiom.lib, and prefer the former; but you don't need to care.

The linkage command succeeds, so now I have a program, axis2c-echo.exe in the same directory. I'll run it:

axis2c-echo

But I can't. I just get a Windows error dialog that says:

This program can't start because axiom.dll is missing from your computer. Try reinstalling the program to fix this error.

The problem is that axiom.dll was linked from C:\develop\stackoverflow\axis2c-x86_64-google\lib, which is not one of the places where the program loader searches for DLLs at runtime.

Now if I planned to be regularly running axis2c programs on my computer, I would solve this by installing the 64-bit axis2c DLLs in C:\Windows\SysWOW64, because 64-bit Windows always searches for DLLs there. But I don't plan to do that, so instead I'll just temporarily add C:\develop\stackoverflow\axis2c-x86_64-google\lib to the Windows DLL Search Path. The last stop on the Windows DLL Search Path is: The directories listed in the PATH environment variable. So at my command prompt I'll enter:

set PATH=%PATH%;C:\develop\stackoverflow\axis2c-x86_64-google\lib

and then run axis2c-echo again. This time, the output is:

AXIS2C_HOME is not set - log is written to . dir Using endpoint : http://localhost:9090/axis2/services/echo Error creating service client, Please check AXIS2C_HOME again

Now the program itself is complaining, but that's good enough for me! It has compiled, linked, loaded, produced some output and finished gracefully.

It's probably obvious now how you would set up a Code::Blocks project to build this same program:

  • Create a C-language console project in the echo directory.
  • Delete the default main.c source file from the project
  • Add the single source file echo.c to the project.
  • In the project's Build options -> Search directories -> Compiler, add C:\develop\stackoverflow\axis2c-x86_64-google\include\axis2-1.6.0 (or path\to\your\axis2c-1.6.0\header-files)
  • In the project's Build options -> Search directories -> Linker, add C:\develop\stackoverflow\axis2c-x86_64-google\lib (or path\to\your\axis2c-1.6.0\libraries)
  • In the project's Build options -> Linker settings -> Other linker options, add -laxiom -laxutil -laxis2_engine -laxis2_parser

This isn't the only way you could successfully configure this project in C::B, but it corresponds to the way someone would normally build the project at the command prompt, and means that the toolchain commands that C::B executes will be concise and normal-looking.

If you follow these steps to build the example echo project you shouldn't have much difficulty successfully configuring your own project.



来源:https://stackoverflow.com/questions/28673278/the-procedure-entry-point-axiom-attribute-create-could-not-be-located-in-the-dyn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!