Google Answers Logo
View Question
 
Q: Compiling and Linking a program ( No Answer,   1 Comment )
Question  
Subject: Compiling and Linking a program
Category: Computers > Programming
Asked by: wallygato-ga
List Price: $10.00
Posted: 13 Jul 2005 09:46 PDT
Expires: 12 Aug 2005 09:46 PDT
Question ID: 543081
I want to be able to compile and link a program called ACCPM. You can
find it on the web at:

http://www.hec.unige.ch/professeurs/VIAL_Jean-Philippe/pages_web/accpm/index.html

along with a user's guide which includes instructions for making it work.

If you can get either the Windows Visual C++ or Linux version compiled
and linked with any of the examples and walk me through a more
detailed process
than is given in the user's guide it would be a sufficient answer.

If you decide to use Linux please use either use Knoppix 3.9 because
it is what is at my disposal, or give me a good reason why I should
download and use another distro for this problem.

Request for Question Clarification by maniac-ga on 16 Jul 2005 21:22 PDT
Hello Wallygato,

The library that efn refers to is part of a package named "f2c" (to
convert fortran to c). It may be that part of the object files in the
ACCPM library require that package.

Please check
  (your directory)/mkhosts/libf2c.a
which should be a library for f2c, suitable for building the
applications. As the README indicates, modify the line in
  (your directory)mkhosts/linux
that reads
  LF77=/usr/lib/libf2c.a
to something like
  (your directory)/mkhosts/libf2c.a
and rerun the
  make all
command in the top level directory.

[alas - I do not have a copy of Knoppix and my Linux box is currently
in pieces so I cannot try what I described above. If this works (or
not), please let me know so I can follow up with a more proper answer]

  --Maniac

Clarification of Question by wallygato-ga on 17 Jul 2005 00:57 PDT
Hi Maniac,

When I modify the line and try to compile and link the "example"
program (I chose to compile just one of the programs instead of all of
them to keep the amount of output manageable) I get the following
output

knoppix@0[example]$ make
cd ../..; make applications "DIRAPPL=applications/example"
make[1]: Entering directory `/ramdisk/home/knoppix'

*************************************
Making applications...
**************************************

CURDIR=`pwd`; \
        for DIR in  applications/example;\
           do\
              cd $CURDIR/$DIR;\
              make "CXX=gcc"       "CC=cc"     "F77=fort77"   
"FFLAGS=-O3" "CFLAGS=-O3 -DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS"
"MAKE=make" "LINK="  "LF77=/home/knoppix/mkfhosts/libf2c.a " "LIBMPI="
"INCMPI=" "MPIRUNOPT=" "LIBCXX=-lgcc" "LM=-lm"     "LIBCPLEX=" 
application ;\
           done
make[2]: Entering directory `/ramdisk/home/knoppix/applications/example'
gcc  -O3 -DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS -I../../libcpm/
-DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS -c  oracle.C -o oracle.o
gcc  -O3 -DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS -I../../libcpm/
-DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS -c  accpm.C -o accpm.o
gcc  oracle.o accpm.o -o ./accpm -L../../libcpm -lACCPM -lm
/home/knoppix/mkfhosts/libf2c.a
oracle.o(.text+0x76): In function `CPM_oracle(Newcut*, int, int,
char*, double*, double**, int, Archive*, user_defined*)':
: undefined reference to `operator new[](unsigned)'
oracle.o(.text+0x153): In function `CPM_oracle(Newcut*, int, int,
char*, double*, double**, int, Archive*, user_defined*)':
: undefined reference to `CPM_build_cut(Newcut*, int, double*, int,
double*, double, int, double, int)'
oracle.o(.text+0x162): In function `CPM_oracle(Newcut*, int, int,
char*, double*, double**, int, Archive*, user_defined*)':
: undefined reference to `operator delete(void*)'
oracle.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
accpm.o(.text+0x1e): In function `main':
: undefined reference to `CPM_coordinator(user_defined*, int, char**)'
accpm.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make[2]: *** [accpm] Error 1
make[2]: Leaving directory `/ramdisk/home/knoppix/applications/example'
make[1]: *** [applications] Error 2
make[1]: Leaving directory `/ramdisk/home/knoppix'
make: *** [prog] Error 2

Request for Question Clarification by maniac-ga on 17 Jul 2005 19:45 PDT
Hello Wallygato,

Hmm. An error like this one...
 ... : undefined reference to `operator new[](unsigned)'
means that the command used to compile a C application was used to
compile a C++ application. Checking the lines above, we see...
  make "CXX=gcc"       "CC=cc"     "F77=fort77"
which implies the use of gcc to compile C++ applications. Checking the
g++ man page at
  http://www.die.net/doc/linux/man/man1/g++.1.html
it notes in part...
  g++ is a script to call gcc with options to recognize C++

Try changing the line in mkhosts/linux from
  CXX= gcc
to
  CXX=g++
and run make again.

  --Maniac

Clarification of Question by wallygato-ga on 18 Jul 2005 13:57 PDT
Maniac,

This modification results in fewer errors. However there are still 2
errors to deal with. the following is the new output:

knoppix@0[example]$ make
cd ../..; make applications "DIRAPPL=applications/example"
make[1]: Entering directory `/ramdisk/home/knoppix'

*************************************
Making applications...
**************************************

CURDIR=`pwd`; \
        for DIR in  applications/example;\
           do\
              cd $CURDIR/$DIR;\
              make "CXX=g++"       "CC=cc"     "F77=fort77"   
"FFLAGS=-O3" "CFLAGS=-O3 -DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS"
"MAKE=make" "LINK="  "LF77=/home/knoppix/mkfhosts/libf2c.a " "LIBMPI="
"INCMPI=" "MPIRUNOPT=" "LIBCXX=-lgcc" "LM=-lm"     "LIBCPLEX=" 
application ;\
           done
make[2]: Entering directory `/ramdisk/home/knoppix/applications/example'
g++  -O3 -DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS -I../../libcpm/
-DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS -c  oracle.C -o oracle.o
g++  -O3 -DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS -I../../libcpm/
-DUNDERSCORE_SPARSE -DUNDERSCORE_BLAS -c  accpm.C -o accpm.o
g++  oracle.o accpm.o -o ./accpm -L../../libcpm -lACCPM -lm
/home/knoppix/mkfhosts/libf2c.a

oracle.o(.text+0x153): In function `CPM_oracle(Newcut*, int, int,
char*, double*, double**, int, Archive*, user_defined*)':
: undefined reference to `CPM_build_cut(Newcut*, int, double*, int,
double*, double, int, double, int)'

accpm.o(.text+0x1e): In function `main':
: undefined reference to `CPM_coordinator(user_defined*, int, char**)'

collect2: ld returned 1 exit status
make[2]: *** [accpm] Error 1
make[2]: Leaving directory `/ramdisk/home/knoppix/applications/example'
make[1]: *** [applications] Error 2
make[1]: Leaving directory `/ramdisk/home/knoppix'
make: *** [prog] Error 2

Request for Question Clarification by maniac-ga on 18 Jul 2005 20:24 PDT
Hello Wallygato,

Hmm. Please try
  nm libcpm/libACCPM.a | grep CPM_oracle  [or CPM_build_cut]
or
  strings libcpm/libACCPM.a | grep CPM_

and you should find that those symbols are defined in the library file libACCPM.a.

If you confirm this, the question then becomes why the command lines
you refer to don't work. One possibility is that the archive provided
does not have a proper symbol table. The error that CPM_Oracle cannot
refer to CPM_build_cut (both are in the archive) makes this likely.
Try either:

  cd libcpm
  cp libACCPM.a libACCPM.keep
  ranlib libACCPM.a
or
  cd libcpm
  cp libACCPM.a libACCPM.keep
  ar -s libACCPM.a
[the cp command is "just in case" there is a problem...]

Then try the makefile again.
  --Maniac

Clarification of Question by wallygato-ga on 19 Jul 2005 16:25 PDT
typing "nm libcpm/libACCPM.a | grep CPM_" produces this output.

All of CPM_build_cut, CPM_oracle and CPM_coordinator appear in the
output. However a function called CPM_oracle is also present in every
examples oracle.c file if that is of any help.

both of the suggested approaches do not reduce the number of error
messages or produce different ones.

Thank you for all your help so far.
knoppix@0[~]$ nm libcpm/libACCPM.a | grep CPM_
00000000 T CPM_update_best__FiPdN21i
         U CPM_add_to_history__FPciiPdT3ddPP7ArchiveG12UserSettingsG6NewcutT3i
00000f90 T CPM_coordinator__FP12user_definediPPc
         U CPM_free_history__FP7Archive
         U CPM_generator__FG12UserSettingsP7ProblemP4WorkPcdRdPdN26dT5cG6Newcut
         U CPM_get_feasibility_cuts__FiP7ArchiveiG12UserSettings
         U CPM_get_optimality_cuts__FiP7ArchiveiG12UserSettings
         U CPM_open_result__FPc
         U CPM_oracle_call__FP6NewcutiG12UserSettingsPcPdPPdiP7ArchiveP12user_definediRdRiT11_
         U CPM_reset_history__FPcG12UserSettings
         U CPM_set_ac_parameters__FG12UserSettingsP7Problem
         U CPM_set_optimality_cuts__FPii
         U CPM_update_best__FiPdN21i
         U CPM_write_iteration__FPciiiddd
         U CPM_write_transition__FPc
00000434 T CPM_build_cut__FP6NewcutiPdiT2didi
00000000 T CPM_get_feasibility_cuts__FiP7ArchiveiG12UserSettings
000
00544 T CPM_get_optimality_cuts__FiP7ArchiveiG12UserSettings
         U CPM_oracle__FP6NewcutiiPcPdPPdiP7ArchiveP12user_defined
00000350 T CPM_oracle_call__FP6NewcutiG12UserSettingsPcPdPPdiP7ArchiveP12user_definediRdRiT11_
0000063c T CPM_set_optimality_cuts__FPii
00000184 T CPM_destroy_cut__FG6Newcut
00000000 T CPM_generator__FG12UserSettingsP7ProblemP4WorkPcdRdPdN26dT5cG6Newcut
000001d0 T CPM_set_ac_parameters__FG12UserSettingsP7Problem
00000554 T CPM_open_result__FPc
0000045c T CPM_write_iteration__FPciiiddd
00000528 T CPM_write_transition__FPc
000002d8 T CPM_add_to_history__FPciiPdT3ddPP7ArchiveG12UserSettingsG6NewcutT3i
00000240 T CPM_free_history__FP7Archive
00000290 T CPM_reset_history__FPcG12UserSettings
00000000 T CPM_write_history__FPciiP7ArchivePdiG12UserSettings
         U ACCPM_allocate_ws__FUiUiRi
         U ACCPM_init_work_space__FPci
         U ACCPM_init_work_space__FPci
         U ACCPM_allocate_ws__FUiUiRi
00000000 T ACCPM_allocate_ws__FUiUiRi
000000b4 T ACCPM_init_work_space__FPci
Answer  
There is no answer at this time.

Comments  
Subject: Re: Compiling and Linking a program
From: efn-ga on 13 Jul 2005 19:53 PDT
 
It looks like the library depends on a Fortran library that is not
supplied in the distribution.  So this appears to be more a problem of
finding software than a problem of building the supplied software.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy