Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

Cannot compile application with ifort

alexvader
Beginner
1,160 Views
Hi Forum

I have downloaded the source code of an application targeted to Finite Elements Analysis, called Calculix,

http://www.calculix.de/
http://www.dhondt.de/

or ccx for short.

I plan to run it under a Debian Lenny amd64, and I have installed the last version of the Intel development tools icc/ifort/mkl, which is 11.1.046-

Anyway, I have already compiled large projects like Code Aster, ( another FEA package ) using these development tools, which means that my development toolset is operational.

So, after compiling the Arpack and Spooles libraries ( mandatory for linking with the calculix binary ) outside of my source tree equally with the intel Dev tools, i proceed to ccx itself.

... but regardlessly of having changed the makefile so as to use icc/ifort, and changing the flags like this :

CFLAGS = -Wall -O3 -I ../../../SPOOLES.2.2 -DARCH="Linux" -DSPOOLES -DARPACK
-DMATRIXSTORAGE
FFLAGS = -Wall -O3 -fopenmp -fltconsistency -nofor_main

CC=icc
FC=ifort

.c.o :
$(CC) $(CFLAGS) -c $<
.f.o :
$(FC) $(FFLAGS) -c $<

include Makefile.inc

SCCXMAIN = ccx_2.0.c

OCCXF = $(SCCXF:.f=.o)
OCCXC = $(SCCXC:.c=.o)
OCCXMAIN = $(SCCXMAIN:.c=.o)

DIR=../../../SPOOLES.2.2

LIBS = \
$(DIR)/spooles.a \
../../../ARPACK/libarpack_INTEL.a \
-lm -lc

ccx_2.0: $(OCCXMAIN) ccx_2.0.a $(LIBS)
./date.pl; $(CC) $(CFLAGS) -c ccx_2.0.c; $(FC) -Wall -O3 -o $@ $(OCCXMAIN)
ccx_2.0.a -lpthread $(LIBS)

ccx_2.0.a: $(OCCXF) $(OCCXC)
ar vr $@ $?


when I type make, after successfully building all the objects and linking with spooles/arpack, the binary is not built, and an error pops out.... :


./date.pl; icc -Wall -O3 -I ../../../SPOOLES.2.2 -DARCH="Linux" -DSPOOLES
-DARPACK -DMATRIXSTORAGE -c ccx_2.0.c; ifort -Wall -O3 -o ccx_2.0 ccx_2.0.o
ccx_2.0.a -lpthread ../../../SPOOLES.2.2/spooles.a
../../../ARPACK/libarpack_INTEL.a -lm -lc
ifort: command line warning #10156: ignoring option '-W'; no argument required
ccx_2.0.o: In function `main':
ccx_2.0.c:(.text+0x0): multiple definition of `main'
/opt/intel/Compiler/11.1/046/lib/intel64/for_main.o:/export/users/nbtester/efi2l
inux_nightly/branch-ubs-11_1/20090701_000000/libdev/frtl/src/libfor/for_main.c:(
.text+0x0): first defined here
/opt/intel/Compiler/11.1/046/lib/intel64/for_main.o: In function `main':
/export/users/nbtester/efi2linux_nightly/branch-ubs-11_1/20090701_000000/libdev/
frtl/src/libfor/for_main.c:(.text+0x38): undefined reference to `MAIN__'
make: *** [ccx_2.0] Error 1
alex@iskandhar:~/Desktop/ccx/CalculiX/ccx_2.0/src$


Can someone advise me on how to proceed...?

Are these the correct flags for compilation... ?

Thanks in advance for yr help :-)


Best regards

Alex
0 Kudos
1 Solution
Ron_Green
Moderator
1,160 Views
Not so hard, we'll get there. Notice that your Fortran Flags were not used. You have a makefile problem with this:

ccx_2.0: $(OCCXMAIN) ccx_2.0.a $(LIBS)
./date.pl; $(CC) $(CFLAGS) -c ccx_2.0.c; $(FC) -Wall -O3 -o $@ $(OCCXMAIN)

Notice that FFLAGS is not used. Try this:

ccx_2.0: $(OCCXMAIN) ccx_2.0.a $(LIBS)
./date.pl; $(CC) $(CFLAGS) -c ccx_2.0.c; $(FC) $(FFLAGS) -o $@ $(OCCXMAIN)

View solution in original post

0 Kudos
6 Replies
TimP
Honored Contributor III
1,160 Views
If the C main() is meant to be the real main program, it may be easier to use icc to drive the link, but you would have to specify the required ifort libraries. Alternatively, you must get -nofor-main working; it looks like the option didn't get set when using ifort to drive the link. You may be correct about alternate spellings for that option.

0 Kudos
alexvader
Beginner
1,160 Views
Quoting - tim18
If the C main() is meant to be the real main program, it may be easier to use icc to drive the link, but you would have to specify the required ifort libraries. Alternatively, you must get -nofor-main working; it looks like the option didn't get set when using ifort to drive the link. You may be correct about alternate spellings for that option.

Hi tim18

The real main c program lives in a file called ccx_2.0.c, I send as attachment...

But i see no multiple definitions to mani()...

I couldn't help noticing that a file called ccx_2.0.a gets created... probably if I change some of the compiler flags in Makefile, the binary gets built...

What would you abdvise me to do...? change the syntax of ccx_2.0.c or change Makefile settings...?

I really do not feel very at ease messing around with a code that I do not wrote/understand what it does...

Even knowing a programming language is not enough to do this without f***ing up the code... this is my experience... :-(

What would you advise me to do...?

Thanks for your reply....


Alex
0 Kudos
Ron_Green
Moderator
1,160 Views
I don't believe you understood Tim's response. The option you use is -nofor_main, that is incorrect. It should be -nofor-main

This prevents ifort from linking in a MAIN() routine into the code and instead lets the C main become the main entry point for the executable.

A simple typo on that compiler option.

ron
0 Kudos
alexvader
Beginner
1,160 Views
I don't believe you understood Tim's response. The option you use is -nofor_main, that is incorrect. It should be -nofor-main

This prevents ifort from linking in a MAIN() routine into the code and instead lets the C main become the main entry point for the executable.

A simple typo on that compiler option.

ron
Hi Ron

Thanks for your hint, but it did not solve much :

So i changed the definition flags to


CFLAGS = -Wall -O3 -I ../../../SPOOLES.2.2 -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE
FFLAGS = -Wall -O3 -fopenmp -fltconsistency -nofor-main


make,

and the following happens...


.............................

./date.pl; icc -Wall -O3 -I ../../../SPOOLES.2.2 -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -c ccx_2.0.c; ifort -Wall -O3 -o ccx_2.0 ccx_2.0.o ccx_2.0.a -lpthread ../../../SPOOLES.2.2/spooles.a ../../../ARPACK/libarpack_INTEL.a -lm -lc
ifort: command line warning #10156: ignoring option '-W'; no argument required
ccx_2.0.o: In function `main':
ccx_2.0.c:(.text+0x0): multiple definition of `main'
/opt/intel/Compiler/11.1/046/lib/intel64/for_main.o:/export/users/nbtester/efi2linux_nightly/branch-ubs-11_1/20090701_000000/libdev/frtl/src/libfor/for_main.c:(.text+0x0): first defined here
/opt/intel/Compiler/11.1/046/lib/intel64/for_main.o: In function `main':
/export/users/nbtester/efi2linux_nightly/branch-ubs-11_1/20090701_000000/libdev/frtl/src/libfor/for_main.c:(.text+0x38): undefined reference to `MAIN__'
make: *** [ccx_2.0] Error 1


I guess this is way trickier than I thought... :-(


Thanks for your answer

Alex
0 Kudos
Ron_Green
Moderator
1,161 Views
Not so hard, we'll get there. Notice that your Fortran Flags were not used. You have a makefile problem with this:

ccx_2.0: $(OCCXMAIN) ccx_2.0.a $(LIBS)
./date.pl; $(CC) $(CFLAGS) -c ccx_2.0.c; $(FC) -Wall -O3 -o $@ $(OCCXMAIN)

Notice that FFLAGS is not used. Try this:

ccx_2.0: $(OCCXMAIN) ccx_2.0.a $(LIBS)
./date.pl; $(CC) $(CFLAGS) -c ccx_2.0.c; $(FC) $(FFLAGS) -o $@ $(OCCXMAIN)
0 Kudos
alexvader
Beginner
1,160 Views
Not so hard, we'll get there. Notice that your Fortran Flags were not used. You have a makefile problem with this:

ccx_2.0: $(OCCXMAIN) ccx_2.0.a $(LIBS)
./date.pl; $(CC) $(CFLAGS) -c ccx_2.0.c; $(FC) -Wall -O3 -o $@ $(OCCXMAIN)

Notice that FFLAGS is not used. Try this:

ccx_2.0: $(OCCXMAIN) ccx_2.0.a $(LIBS)
./date.pl; $(CC) $(CFLAGS) -c ccx_2.0.c; $(FC) $(FFLAGS) -o $@ $(OCCXMAIN)


Man, kudos for you.... :-)

You solved the problem, in fact, this was a makefile problem... the binary was built.

Thanks a lot for yr help ;-)

Greetz


Alex
0 Kudos
Reply