On 10/02/11 06:54, Mariwan wrote:
> HI,
> I have a problem in linking some .o object to the executable file in linux
> (fedora).
> com.o uiciname.o uici.o restart.o are written in c and I use gcc to compile
> them.
> but client.o is a fltk program. and I use g++ to compile it.
That should be fine, and is probably not the issue.
Note that FLTK itself has a bit of .c code, eg:
$ cd fltk-1.3.x/src
$ ls *.c
dump_compose.c fl_call_main.c fl_utf.c flstring.c numericsort.c scandir.c
scandir_win32.c vsnprintf.c
If I comment out .SILENT from fltk's makeinclude file and rebuild
eg. the fl_utf.o module, I see it uses gcc to build it, eg:
$ rm fl_utf.o
$ make
Compiling fl_utf.c...
gcc -I.. -Os -Wall -Wunused -Wno-format-y2k -fno-exceptions
-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE
-D_REENTRANT -I/usr/include/freetype2 -c fl_utf.c -o fl_utf.o
[..]
..the rest of fltk builds with g++.
All the .o's are put into the lib, so it's the same situation.
> here is the out put of the make:
>
> g++ -o Client client.o com.o uiciname.o uici.o restart.o
> -L/usr/X11R6/lib -L/usr/local/lib -lX11 -lfltk -lfltk_images -lm -lXpm
> -lpng -lz -ljpeg
> client.o: In function `main':
> client.cxx:(.text.startup+0x3bb): undefined reference to
> `connectToServer(char const*, unsigned short, char const*, char const*)'
> client.cxx:(.text.startup+0x3e8): undefined reference to
> `stratChatReceiving(int*, char*)'
> client.cxx:(.text.startup+0x49f): undefined reference to
> `startChatSending(int*, char const*)'
> collect2: ld returned 1 exit status
> make: *** [Client] Error 1
Which module are the functions 'connectToServer()' and
'stratChatReceiving()' (etc)
defined? Is that module's .o newer than the .c?
Also: do the arguments shown in the error above
match the arguments in the actual function definition?
(Perhaps you modified one of the arguments in the actual function
but forgot to modify your calls or externs to match it)
Any of the following, and possibly more could cause the above
errors:
o The module those functions are defined in is not in your g++
link line
o The module is specified, but the code is somehow not being
compiled (due to an errant #ifdef)
o The module is specified and the code is compiled, but one of
the functions arguments has changed
and has either not been re-compiled, or was recompiled, but
the extern references in the .h
were not changed to match the code's new argument
The above error literally means the linker sees client.cxx's main()
trying to call those functions with those exact arguments (check them)
but can't find a match in any of the .o's you've listed.
Try doing a 'make clean; make' which should remove all the .o files
and rebuild them, in case your makefile isn't rebuilding .o's for
some reason.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk