coin-or / OS

Optimization Services
Other
1 stars 4 forks source link

Make test fails for CBC with 78 unresolved external symbols when building using msvc at command line #62

Open svigerske opened 5 years ago

svigerske commented 5 years ago

Issue created by migration from Trac.

Original creator: devos

Original creation time: 2018-01-03 09:01:27

Keywords: trunk 5287, OS, CBC

Using Microsoft cl compiler and MSYS following instructions in Optimization Services Manual, make test fails for trunk d2ae03ae1a -- cbc.exe : fatal error LNK1120: 78 unresolved externals (see attached maketest.log, make.log, config.log, config-cbc.log, config-cgl.log).

Also attached are a file containing all environment variables as defined in MSYS prompt window (msys_vars.log) and config.site file. I discovered that I had to add the 'enable_msvc=yes' configuration option to get CppAD to build.

I skipped Ipopt, DyLP, Couenne, Bonmin, Vol, and SYMPHONY and have only Glpk, ASL, and Metis in third party. (I excluded Ipopt, Mumps, Blas, and Lapack due to lack of a Fortran compiler.)

  1. Is there some other configuration option that must be included to allow CBC to build?

  2. Is there some misconfiguration of my environment variables or incompatibility among the components?

  3. Did CBC fail due to one of the third party projects that were excluded?

  4. Is there a change needed to the make file?

  5. Or something else?

svigerske commented 5 years ago

Attachment config.site by devos created at 2018-01-03 09:02:42

svigerske commented 5 years ago

Attachment config.log by devos created at 2018-01-03 09:02:58

svigerske commented 5 years ago

Attachment config-cbc.log by devos created at 2018-01-03 09:03:14

svigerske commented 5 years ago

Attachment config-cgl.log by devos created at 2018-01-03 09:03:27

svigerske commented 5 years ago

Attachment msys_vars.log by devos created at 2018-01-03 09:03:44

svigerske commented 5 years ago

Attachment make.log by devos created at 2018-01-03 09:03:57

svigerske commented 5 years ago

Attachment maketest.log by devos created at 2018-01-03 09:04:08

svigerske commented 5 years ago

Comment by @tkralphs created at 2018-01-04 15:40:17

Most likely, the problem is that you need the dos2unix command installed. See

https://projects.coin-or.org/OS/attachment/ticket/62/make.log#L2747

I don't recall if that command can be installed with pacman, but some Googling should yield a solution. I guess we should be checking for dos2unix and throwing an error in configuration if it's not found. I opened a new issue here.

svigerske commented 5 years ago

Comment by devos created at 2018-01-04 15:58:38

Thank you. I have installed dos2unix and will run make again now.

svigerske commented 5 years ago

Comment by devos created at 2018-01-04 20:54:29

Installing dos2unix seems to have addressed the 78 unresolved externals for CBC. Now there is an error that seems to be related to CppAD and SPEED_DIRS:

make[1]: Leaving directory `/c/coin-os/5287.1/Cbc'

Making all in cppad

make[1]: Entering directory `/c/coin-os/5287.1/cppad'

cp cppad/configure.hpp ../../cppad/cppad/configure.hpp

SPEED_DIRS =

make[1]: SPEED_DIRS: Command not found

make[1]: * [../../cppad/cppad/configure.hpp] Error 127

make[1]: Leaving directory `/c/coin-os/5287.1/cppad'

make: * [all-recursive] Error 1

There are also 14 occurrences of the following warning; it was also in the last make. Will this cause any problems?:

libtool: link: warning: undefined symbols not allowed in i686-pc-mingw32 shared libraries

svigerske commented 5 years ago

Attachment [make 1-4-18 141pm.log](https://www.coin-or.org/issue-attachments/OS/ticket62/make 1-4-18 141pm.log) by devos created at 2018-01-04 20:55:19

svigerske commented 5 years ago

Comment by devos created at 2018-01-04 21:05:36

I also got the following warning. Do I need to do anything for this?:

*** Warning: Trying to link with static lib archive libamplsolver.lib.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because the file extensions .lib of this argument makes me believe
*** that it is just a static archive that I should not used here.
svigerske commented 5 years ago

Comment by devos created at 2018-01-04 21:36:25

I found two recommendations online regarding the libtool: link: warning: undefined symbols not allowed in i686-pc-mingw32 shared libraries. Do you recommend either/both of these solutions?:

Solution 1:
On Windows, libtool needs -no-undefined to be able to link shared DLLs. Many projects are already forcing -no-undefined, but some are not. If this is the problem, the log should show something like this (extracted from apr log):
libtool: link: warning: undefined symbols not allowed in i686-pc-mingw32.shared shared libraries
If this happens, simply add LDFLAGS=-no-undefined to the make command, and it should fix the problem.

Solution 2:
In your configure.ac, make sure your libtool initialization looks like:
LT_INIT([win32-dll])
Also, you need to pass -no-undefined flag to libtool in your Makefile.am. This flag disables the warning you are getting:
libexample_la_LDFLAGS = -no-undefined
More details about this in the LT_INIT documentation.
svigerske commented 5 years ago

Comment by devos created at 2018-01-05 14:53:35

I have attached the config.log from the cppad subdirectory (config-cppad.log). Could the errors reported there be the cause of the 'SPEED_DIRS: Command not found' error?

svigerske commented 5 years ago

Attachment config-cppad.log by devos created at 2018-01-05 14:54:49

svigerske commented 5 years ago

Comment by devos created at 2018-01-05 18:58:12

The makefile in the cppad subdirectory has these lines:

IPOPT_HEADER = 
#
#IPOPT_HEADER = \
#   cppad_ipopt/src/cppad_ipopt_nlp.hpp

#
# Is the library archiving program present
#SPEED_TESTS = \
#   $(SPEED_ADOLC_TESTS)  \
#   speed/cppad \
#   speed/double \
#   speed/example \
#   $(SPEED_FADBAD_TESTS) \
#   speed/profile \
#   $(SPEED_SACADO_TESTS)

#
#SPEED_DIRS = \
#   speed/src \
#   $(SPEED_TESTS)

Maybe these lines were commented out because Ipopt was skipped in the configuration step.

If I build CppAD using cmake prior to running configure, how would I prevent configure from writing over the CppAD make files?

svigerske commented 5 years ago

Comment by devos created at 2018-01-05 19:21:26

I found these lines in cppad\makefile.am.

# Is the library archiving program present
if CppAD_HAVE_AR
SPEED_TESTS = \
    $(SPEED_ADOLC_TESTS)  \
    speed/cppad \
    speed/double \
    speed/example \
    $(SPEED_FADBAD_TESTS) \
    speed/profile \
    $(SPEED_SACADO_TESTS)
#
SPEED_DIRS = \
    speed/src \
    $(SPEED_TESTS)
else
    SPEED_DIRS =
endif

My problem may be that CppAD_HAVE_AR is not set. Where/how do I set that?

svigerske commented 5 years ago

Comment by devos created at 2018-01-08 22:04:13

I was finally able to get the build to complete. These are the steps I took: