Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
svigerske opened this issue Mar 5, 2019 · 18 comments

Comments

@svigerske
Copy link
Member

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 d2ae03a -- 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
Copy link
Member Author

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

@svigerske
Copy link
Member Author

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

@svigerske
Copy link
Member Author

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

@svigerske
Copy link
Member Author

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

@svigerske
Copy link
Member Author

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

@svigerske
Copy link
Member Author

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

@svigerske
Copy link
Member Author

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

@svigerske
Copy link
Member Author

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
Copy link
Member Author

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

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

@svigerske
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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

@svigerske
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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:

  • I had to uninstall the smaller MSYS installation and install MinGW (www.mingw.org) to get the ar and dos2unix programs. I installed only mingw32-base, msys-base, msys-patch, msys-unzip. I also installed msys-perl and msys-m4 because I needed to build autotools to fix another issue.
  • Because the OS 2.10 User's Manual states that the gcc compiler included in MinGW can interact negatively with the Microsoft cl compiler, I removed gcc from the MinGW installation. These components of 'The GNU C Compiler' were removed: mingw32-gcc bin, mingw32-gcc dev, mingw32-gcc lic. 'The GNU C Compiler Shared Runtime Library' (mingw32-libgcc dll) must be kept because dos2unix depends on it.
  • I added the configuration option --enable-msvc to force use of the cl compiler.
  • I added LDFLAGS=-no-undefined to the make command to pass this option to libtool to enable it to link shared DLLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant