문제

I'm trying to compile a C program using libxml2 in Eclipse. It seems like my code doesn't have problems, but there are errors when I build my project.

The error output is in this screenshot: https://drive.google.com/file/d/0BwV-0_2diIaaQlZHM2Fwa2R0LWc/edit

Before this error, I had an “Undefined reference to” error, but it was because I forgot to link the library libxml2. Now it's the problem in the screenshot. I don't what to do.

[EDITED] I solved my problem I just need to put -nostartfiles in the linker flags.

도움이 되었습니까?

해결책

I solved my problem I just need to write -nostartfiles in the Linker Flags box :D To find "Linker Flags" box go to Your Project > Properties > C/C++Build > Settings > GCC C Linker > Miscellaneous

That's it.

Thanks for help.

다른 팁

I don't think your solution is acceptable, I think it will lead to the same problem when your project is executed in other environment (another eclipse configuration, running it from console, etc) That error occurs when you have defined the same function more than one time in your project, and I bet it's because you have defined the same function you already had in a library.

For example, if I have lib1.h with a function called hello() and then write the same function in your main.c (having that library linked) that problem will occur. In fact, in your image, I can see "multiple definition of __data_start"

So I think you just have to change the problematic function name and it will be fixed.

In addition, this problem will be caused if you include the same library more than once in your program, but it can be solved using preprocessor (if you are interested in this, google it, since it would be off-topic and make my answer too long)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top