Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

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

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:WindowsSysWOW64" as @mikekinghan suggested.

Here is the build log :

-------------- Build: Debug in Math ---------------

mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathadb_addOperatorResponse.c -o objDebugadb_addOperatorResponse.o
In file included from C:Toolsaxis2cinclude/platforms/axutil_platform_auto_sense.h:40,
                 from C:Toolsaxis2cinclude/axutil_dll_desc.h:31,
                 from C:Toolsaxis2cinclude/axutil_class_loader.h:31,
                 from C:Toolsaxis2cinclude/axis2_util.h:24,
                 from E:devcMathadb_addOperatorResponse.h:21,
                 from E:devcMathadb_addOperatorResponse.c:10:
C:Toolsaxis2cinclude/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:devcMathadb_addOperatorResponse.c: In function 'adb_addOperatorResponse_serialize_obj':
E:devcMathadb_addOperatorResponse.c:466: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
E:devcMathadb_addOperatorResponse.c:374: warning: unused variable 'ns_already_defined'
E:devcMathadb_addOperatorResponse.c:372: warning: unused variable 'qname_prefix'
E:devcMathadb_addOperatorResponse.c:371: warning: unused variable 'qname_uri'
E:devcMathadb_addOperatorResponse.c:367: warning: unused variable 'tag_closed'
E:devcMathadb_addOperatorResponse.c: In function 'adb_addOperatorResponse_reset_addOperatorReturn':
E:devcMathadb_addOperatorResponse.c:568: warning: unused variable 'element'
E:devcMathadb_addOperatorResponse.c:567: warning: unused variable 'count'
E:devcMathadb_addOperatorResponse.c:566: warning: unused variable 'i'
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathaxis2_extension_mapper.c -o objDebugaxis2_extension_mapper.o
In file included from C:Toolsaxis2cinclude/platforms/axutil_platform_auto_sense.h:40,
                 from C:Toolsaxis2cinclude/axutil_dll_desc.h:31,
                 from C:Toolsaxis2cinclude/axutil_class_loader.h:31,
                 from C:Toolsaxis2cinclude/axis2_util.h:24,
                 from E:devcMathaxis2_extension_mapper.h:14,
                 from E:devcMathaxis2_extension_mapper.c:10:
C:Toolsaxis2cinclude/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:devcMathaxis2_extension_mapper.c: In function 'axis2_extension_mapper_type_from_node':
E:devcMathaxis2_extension_mapper.c:31: warning: unused variable 'element_qname'
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathaxis2_stub_MathService.c -o objDebugaxis2_stub_MathService.o
In file included from C:Toolsaxis2cinclude/platforms/axutil_platform_auto_sense.h:40,
                 from C:Toolsaxis2cinclude/axutil_dll_desc.h:31,
                 from C:Toolsaxis2cinclude/axutil_class_loader.h:31,
                 from C:Toolsaxis2cinclude/axis2_util.h:24,
                 from C:Toolsaxis2cinclude/neethi_includes.h:22,
                 from C:Toolsaxis2cinclude/neethi_operator.h:29,
                 from C:Toolsaxis2cinclude/neethi_policy.h:29,
                 from C:Toolsaxis2cinclude/axis2_svc_client.h:56,
                 from C:Toolsaxis2cinclude/axis2_stub.h:35,
                 from C:Toolsaxis2cinclude/axis2_client.h:31,
                 from E:devcMathaxis2_stub_MathService.h:14,
                 from E:devcMathaxis2_stub_MathService.c:10:
C:Toolsaxis2cinclude/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:devcMathaxis2_stub_MathService.c: In function 'axis2_stub_populate_services_for_MathService':
E:devcMathaxis2_stub_MathService.c:72: warning: unused variable 'status'
E:devcMathaxis2_stub_MathService.c:71: warning: unused variable 'neethi_policy'
E:devcMathaxis2_stub_MathService.c:70: warning: unused variable 'policy_root_ele'
E:devcMathaxis2_stub_MathService.c:69: warning: unused variable 'policy_node'
E:devcMathaxis2_stub_MathService.c:68: warning: unused variable 'desc'
E:devcMathaxis2_stub_MathService.c:66: warning: unused variable 'policy_include'
E:devcMathaxis2_stub_MathService.c: In function 'axis2_stub_on_complete_MathService_addOperator':
E:devcMathaxis2_stub_MathService.c:277: warning: unused variable 'soap_fault'
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathmain.c -o objDebugmain.o
In file included from C:Toolsaxis2cinclude/platforms/axutil_platform_auto_sense.h:40,
                 from C:Toolsaxis2cinclude/axutil_dll_desc.h:31,
                 from C:Toolsaxis2cinclude/axutil_class_loader.h:31,
                 from C:Toolsaxis2cinclude/axis2_util.h:24,
                 from C:Toolsaxis2cinclude/neethi_includes.h:22,
                 from C:Toolsaxis2cinclude/neethi_operator.h:29,
                 from C:Toolsaxis2cinclude/neethi_policy.h:29,
                 from C:Toolsaxis2cinclude/axis2_svc_client.h:56,
                 from C:Toolsaxis2cinclude/axis2_stub.h:35,
                 from C:Toolsaxis2cinclude/axis2_client.h:31,
                 from E:devcMathaxis2_stub_MathService.h:14,
                 from E:devcMathmain.c:1:
C:Toolsaxis2cinclude/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:devcMathmain.c:3: warning: second argument of 'main' should be 'char **'
E:devcMathmain.c: In function 'main':
E:devcMathmain.c:8: warning: unused variable 'operation'
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathadb_addOperator.c -o objDebugadb_addOperator.o
In file included from C:Toolsaxis2cinclude/platforms/axutil_platform_auto_sense.h:40,
                 from C:Toolsaxis2cinclude/axutil_dll_desc.h:31,
                 from C:Toolsaxis2cinclude/axutil_class_loader.h:31,
                 from C:Toolsaxis2cinclude/axis2_util.h:24,
                 from E:devcMathadb_addOperator.h:21,
                 from E:devcMathadb_addOperator.c:10:
C:Toolsaxis2cinclude/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:devcMathadb_addOperator.c: In function 'adb_addOperator_serialize_obj':
E:devcMathadb_addOperator.c:574: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
E:devcMathadb_addOperator.c:640: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
E:devcMathadb_addOperator.c:480: warning: unused variable 'ns_already_defined'
E:devcMathadb_addOperator.c:478: warning: unused variable 'qname_prefix'
E:devcMathadb_addOperator.c:477: warning: unused variable 'qname_uri'
E:devcMathadb_addOperator.c:473: warning: unused variable 'tag_closed'
E:devcMathadb_addOperator.c: In function 'adb_addOperator_reset_num1':
E:devcMathadb_addOperator.c:742: warning: unused variable 'element'
E:devcMathadb_addOperator.c:741: warning: unused variable 'count'
E:devcMathadb_addOperator.c:740: warning: unused variable 'i'
E:devcMathadb_addOperator.c: In function 'adb_addOperator_reset_num2':
E:devcMathadb_addOperator.c:848: warning: unused variable 'element'
E:devcMathadb_addOperator.c:847: warning: unused variable 'count'
E:devcMathadb_addOperator.c:846: warning: unused variable 'i'
mingw32-g++.exe -LC:Toolsaxis2cinclude -LE:devCodeBlocksMinGWlib  -o binDebugMath.exe objDebugadb_addOperatorResponse.o objDebugaxis2_extension_mapper.o objDebugaxis2_stub_MathService.o objDebugmain.o objDebugadb_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.

enter image description here enter image description here enter image description here

I build the project then I get this :

-------------- Build: Debug in Math ---------------

mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathadb_addOperatorResponse.c -o objDebugadb_addOperatorResponse.o
In file included from C:Toolsaxis2cinclude/platforms/axutil_platform_auto_sense.h:40,
                 from C:Toolsaxis2cinclude/axutil_dll_desc.h:31,
                 from C:Toolsaxis2cinclude/axutil_class_loader.h:31,
                 from C:Toolsaxis2cinclude/axis2_util.h:24,
                 from E:devcMathadb_addOperatorResponse.h:21,
                 from E:devcMathadb_addOperatorResponse.c:10:
C:Toolsaxis2cinclude/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
E:devcMathadb_addOperatorResponse.c: In function 'adb_addOperatorResponse_serialize_obj':
E:devcMathadb_addOperatorResponse.c:466: warning: format '%I32d' expects type 'long int', but argument 3 has type 'int'
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathaxis2_extension_mapper.c -o objDebugaxis2_extension_mapper.o
In file included from C:Toolsaxis2cinclude/platforms/axutil_platform_auto_sense.h:40,
                 from C:Toolsaxis2cinclude/axutil_dll_desc.h:31,
                 from C:Toolsaxis2cinclude/axutil_class_loader.h:31,
                 from C:Toolsaxis2cinclude/axis2_util.h:24,
                 from E:devcMathaxis2_extension_mapper.h:14,
                 from E:devcMathaxis2_extension_mapper.c:10:
C:Toolsaxis2cinclude/platforms/windows/axutil_windows.h:221:5: warning: "/*" within comment
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathaxis2_stub_MathService.c -o objDebugaxis2_stub_MathService.o
In file included from C:Toolsaxis2cinclude/platforms/axutil_platform_auto_sense.h:40,
                 from C:Toolsaxis2cinclude/axutil_dll_desc.h:31,
                 from C:Toolsaxis2cinclude/axutil_class_loader.h:31,
                 from C:Toolsaxis2cinclude/axis2_util.h:24,
                 from C:Toolsaxis2cinclude/neethi_includes.h:22,
                 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathadb_addOperatorResponse.c -o objDebugadb_addOperatorResponse.o
...
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathaxis2_extension_mapper.c -o objDebugaxis2_extension_mapper.o
...
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathaxis2_stub_MathService.c -o objDebugaxis2_stub_MathService.o
...
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathmain.c -o objDebugmain.o
...
mingw32-gcc.exe -Wall  -g    -IC:Toolsaxis2cinclude -IE:devCodeBlocksMinGW  -c E:devcMathadb_addOperator.c -o objDebugadb_addOperator.o
...

and then there is a link command:

mingw32-g++.exe -LC:Toolsaxis2cinclude -LE:devCodeBlocksMinGWlib  -o binDebugMath.exe objDebugadb_addOperatorResponse.o objDebugaxis2_extension_mapper.o objDebugaxis2_stub_MathService.o objDebugmain.o objDebugadb_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:MinGWin, 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:Toolsaxis2cinclude => Search for non-standard header files in C:Toolsaxis2cinclude
  • -IE:devCodeBlocksMinGW => Also search for non-standard header files in E:devCodeBlocksMinGW
  • -c => Just compile; don't link
  • E:devcMathsome_filename.c => Compile this file.
  • -o objDebugsome_filename.o => Output the object file objDebugsome_filename.o

And here's what your link command means:

  • -LC:Toolsaxis2cinclude => Search for non-standard libraries (.lib, .a, .dll) in C:Toolsaxis2cinclude
  • -LE:devCodeBlocksMinGWlib => Also search for non-standard libraries in E:devCodeBlocksMinGWlib
  • -o binDebugMath.exe => Output the executable binDebugMath.exe
  • objDebugadb_addOperatorResponse.o => Link this object file
  • objDebugaxis2_extension_mapper.o => Also link this object file
  • objDebugaxis2_stub_MathService.o => Also link this object file
  • objDebugmain.o => Also link this object file
  • objDebugadb_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:Toolsaxis2cinclude
E:devCodeBlocksMinGWlib

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

-IC:Toolsaxis2cinclude

So if that's where the axis2c header files are, then the libraries, I guess, are in C:Toolsaxis2clib. Have a look. Assuming that's right, then in the C::B IDE you need to delete the wrong C:Toolsaxis2cinclude from Search directories -> Linker for your project and replace it with the correct C:Toolsaxis2clib Leave C:Toolsaxis2cinclude 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:Toolsaxis2c-x86-google.

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

C:Toolsaxis2cinclude

to:

C:Toolsaxis2c-x86-googleincludeaxis2-1.6.0

and in Search directories -> Linker, change:

C:Toolsaxis2clib

to:

C:Toolsaxis2c-x86-googlelib

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:

<block

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...