- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a old fortran code containing C program files also. I am trying to compile it using ifort and icc. I am facing issues with linking the X11 library with ifort. When I try to compile the program using ifort -o swbplot swbplot.o xplotlib.o marker.o ttsubs.o libX11.o -lX11
it shows undefined reference to
ld: xplotlib.f:(.text+0x9f): undefined reference to `x_linestyle_'
ld: xplotlib.f:(.text+0x132): undefined reference to `x_setfont_'
ld: xplotlib.f:(.text+0x15a): undefined reference to `x_getfontmap_'
ld: xplotlib.f:(.text+0x20b): undefined reference to `x_setfont_'
ld: xplotlib.f:(.text+0x373): undefined reference to `x_getfontmap_'
ld: xplotlib.f:(.text+0x3b0): undefined reference to `x_setcol_'
..........
I have tried using various linking options but not successful.
What is the issue. I have enclosed the code here.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello singhpu,
Thank you for posting on the Intel® communities.
We are moving this to another Forum support so you can get further assistance.
Regards,
Adrian M.
Intel Customer Support Technician
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The basic problem is that you are not using the name decoration conventions consistently. C, Fortran and the system libraries must all agree with respect to case of names and added underscores, and calling conventions.
Here is an example of the mismatch. From the *.o files in your attachment, I find:
T:\lang\x11\code>nm -g X11lib.o | grep -i twin
0000000000000000 T x_getwin
00000000000001e0 T x_setwin
T:\lang\x11\code>nm -g xplotlib.o | grep -i twin
U x_getwin_
U x_setwin_
Thus, one object has no underscore at the end, the other does. To fix this, you need to examine the commands used to generate these object files from their respective C or Fortran sources, and use the appropriate options to generate or suppress the underscores. The compiler documentation contains extensive coverage of these issues, and is well worth reading before you attempt to recompile and relink.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have one C program and rest of the programs are written in fortran language.
I have compiled C program X11lib.c using icc compiler
>>> icc -c X11lib.c -I/usr/include/X11 -L/usr/lib/x86_64-linux-gnu -lX11
and for fortran programs i am using ifort e.g.
>>> ifort -c swbplot.f -I/usr/include/X11 -L/usr/lib/x86_64-linux-gnu -lX11
I have used x86_64-linux-gnu since /usr/lib/X11/ donot contain libX11.so files. These are located in /usr/lib/x86_64-linux-gnu
When I try to compile all object files simultaneously using ifort
>> ifort -o swbplt1 swbplot.o xplotlib.o marker.o ttsubs.o X11lib.o -I/usr/include/X11 -L/usr/lib/x86_64-linux-gnu -lX11
I encounter same error of undefined references.
ld: xplotlib.o: in function `MAIN__':
xplotlib.f:(.text+0x0): multiple definition of `MAIN__'; swbplot.o:swbplot.f:(.text+0x0): first defined here
ld: swbplot.o: in function `MAIN__':
swbplot.f:(.text+0x1f06): undefined reference to `grstrt_'
ld: swbplot.f:(.text+0x2d1f): undefined reference to `x_locate_'
ld: swbplot.o: in function `key_wait_':
swbplot.f:(.text+0x33e5): undefined reference to `x_locate_'
ld: xplotlib.o: in function `MAIN__':
xplotlib.f:(.text+0x66): undefined reference to `x_mapwindow_'
ld: xplotlib.f:(.text+0x9f): undefined reference to `x_linestyle_'
ld: xplotlib.f:(.text+0x132): undefined reference to `x_setfont_'
ld: xplotlib.f:(.text+0x15a): undefined reference to `x_getfontmap_'
ld: xplotlib.f:(.text+0x20b): undefined reference to `x_setfont_'
ld: xplotlib.f:(.text+0x373): undefined reference to `x_getfontmap_'
ld: xplotlib.f:(.text+0x3b0): undefined reference to `x_setcol_'
ld: xplotlib.f:(.text+0x3c4): undefined reference to `x_setcol_'
ld: xplotlib.f:(.text+0x452): undefined reference to `x_fillrectangle_'
ld: xplotlib.f:(.text+0xa58): undefined reference to `x_iconifywindow_'
ld: xplotlib.f:(.text+0xb14): undefined reference to `x_drawhist_'
ld: xplotlib.f:(.text+0xb58): undefined reference to `x_drawlines_'
ld: xplotlib.f:(.text+0xbaa): undefined reference to `x_drawhist_'
ld: xplotlib.f:(.text+0xbf5): undefined reference to `x_drawlines_'
ld: xplotlib.f:(.text+0xc40): undefined reference to `x_setcol_'
.......
All source codes and files are attached.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for reply. From your suggestion, I figured out that "-assume nounderscore" is the key to most of issues while compiling programs.
By using
ifort -assume nounderscore -o swbplt1 swbplot.o xplotlib.o marker.o ttsubs.o X11lib.o -I/usr/include/X11 -L/usr/lib/x86_64-linux-gnu -lX11
most of the undefined references are removed.
However, some error still presist:
ld: xplotlib.o: in function `MAIN__':
xplotlib.f:(.text+0x0): multiple definition of `MAIN__'; swbplot.o:swbplot.f:(.text+0x0): first defined here
ld: swbplot.o: in function `MAIN__':
swbplot.f:(.text+0x1f06): undefined reference to `grstrt'
Suggest some solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have to have a reasonable idea of what you are trying to do, and a reasonable understanding of the rules for building and linking programs from sources.
You have two Fortran sources, xplotlib/xplotlib.f, and swbplot/swbplot.f, both of which contain main program units. You cannot build a Fortran program with more than one main program unit.
Your swplot.f contains a call to a subroutine named "grstrt", yet there is no subroutine/function with that name in any of your C and Fortran source files. You have to find out if that subroutine is needed, what it is supposed to do, etc., and furnish the source code for that. We do not have that information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After commenting the statement for 'grstrt', I have tried creating shared library for xplotlib.f and swbplot.f using
>> ifort -assume nounderscore -c xplotlib.f swbplot.f -I/usr/include/X11 -L/usr/lib/x86_64-linux-gnu -lX11
>> ar cr foo.a swbplot.o xplotlib.o
and compiled the code using -nofor-main and -assume nounderscore
ifort -nofor-main -assume nounderscore -o swbplt marker.o ttsubs.o X11lib.o foo.a -I/usr/include/X11 -L/usr/lib/x86_64-linux-gnu -lX11
It does compile without any error.
However, grstrt issue still persist.
GRSTRT is graphics start command. other example commands is GRSTOP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems that GRSTRT came from Interactive Graphics Library (IGL) so you need to add it to your linker path. I was able to find several PDF articles mentioning call to GRSTRT and most of that articles were devoted to very old Fortran applications in different domains. It is hard to say more because it is likely that IGL is a proprietary product and I wasn't able to find their website or any other documents.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We will no longer monitor this thread.
If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page