LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why GCC compiling went wrong? One step is btter than two steps? (https://www.linuxquestions.org/questions/linux-newbie-8/why-gcc-compiling-went-wrong-one-step-is-btter-than-two-steps-872523/)

nwpuhlh 04-02-2011 01:47 AM

Why GCC compiling went wrong? One step is btter than two steps?
 
Hi, when I was trying to compile a program to validate a SCEW lib, GCC prompted some strange errors... Could anyone pls give a quick shot? Thanks!

Compling&Linking in one command is OK, but after I separated it into two command it went wrong,,,

[root@fileserver2 common]# gcc scew_print.c -L ./scew -lscew -lexpat -I ./scew -o kkk
[root@fileserver2 common]# ./kkk
Usage: scew_print file.xml
[root@fileserver2 common]# gcc -I ./scew -c scew_print.c
[root@fileserver2 common]# gcc -L ./scew -lscew -lexpat -I ./scew -o kkk scew_print.o
scew_print.o: In function `print_attributes':
scew_print.c:(.text+0x43): undefined reference to `scew_element_attributes'
scew_print.c:(.text+0x53): undefined reference to `scew_list_data'
scew_print.c:(.text+0x61): undefined reference to `scew_attribute_value'
scew_print.c:(.text+0x6e): undefined reference to `scew_attribute_name'
scew_print.c:(.text+0x8d): undefined reference to `scew_list_next'
(rest of erro msg were deleted...)

PS: libscew.a is compiled by " ar -rc libscew.a $(OBJS)"...

nwpuhlh 04-02-2011 02:00 AM

After change the parameters order, it works! why?
 
I just changed the order of parameters it works! Why?

[root@fileserver2 common]# gcc -o kkk scew_print.o -L ./scew -lscew -lexpat -I ./scew
[root@fileserver2 common]# ./kkk
Usage: scew_print file.xml


All times are GMT -5. The time now is 02:16 PM.