problems with make/gcc on Solaris
852321Mar 7 2012 — edited Mar 8 2012I'm working on building a binary on several different platforms, but the only one giving me trouble is Solaris 10 (64-bit -- though apparently this is building a 32-bit binary). The binary relies on the following project:
https://projects.coin-or.org/Cbc
I can checkout their code from SVN and build it without a problem. However, we then have a small cpp file that links to those libraries. I cannot get this cpp file to build. In fact, Solaris chokes on the makefile itself complaining that one of the lines ends with the '$' (which it does). The strange thing is, this makefile works correctly on Linux. It also works just fine on Windows in the MinGW environment (I do have to add a few flags on Windows but they are completely unrelated and the line ending with '$' still still present and works).
Since the makefile failed, I tried to run the 2 commands that it does manually. The first one succeeds but the second command fails to locate the dynamic libraries -- even though the directory they reside in is specified in the -L argument. What gives??
I put /usr/ccs/bin and /usr/sfw/bin in my PATH variable so that I can use make and gcc. I had to add /usr/sfw/lib to the LIBDIR variable, otherwise I was getting even more errors. Here is the makefile and the error that I get when I try to run make:
-----
-bash-3.2$ cat makefile
CPP = gcc
COINPATH = /export/home/locuser/cbc_source/coin-cbc
CPATH += -I$(COINPATH)/include/coin
LIBDIR = -L$(COINPATH)/lib:/usr/sfw/lib
COINLIBS = -lCbcSolver -lCbc -lCgl -lOsiClp -lClp -lOsi -lCoinUtils -lm
CFLAGS += -DUSE_SNAPSHOT=1 -DNEW_SIMULATOR=1 -g $(CPATH)
DATASTORE=$(PSASRC)/datastore.a
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
.cpp.o:
$(CPP) $(CFLAGS) -c -o $@ $<
OBJSx = cbc.o
cbc: $(OBJSx) $
$(CPP) $(CFLAGS) -o cbc $+ $(LIBDIR) $(COINLIBS)
-bash-3.2$ make
mksh: Fatal error in reader: '$' at end of line
Current working directory /export/home/locuser/cbc_source/solver
-----
Then this is what happened when I tried to run the 2 commands manually:
-----
-bash-3.2$ gcc -DUSE_SNAPSHOT=1 -DNEW_SIMULATOR=1 -g -I/export/home/locuser/cbc_source/coin-cbc/include/coin -c -o cbc.o cbc.cpp
-bash-3.2$ gcc -DUSE_SNAPSHOT=1 -DNEW_SIMULATOR=1 -g -I/export/home/locuser/cbc_source/coin-cbc/include/coin -o cbc cbc.o -L/export/home/locuser/cbc_source/coin-cbc/lib:/usr/sfw/lib -lCbcSolver -lCbc -lCgl -lOsiClp -lClp -lOsi -lCoinUtils -lm
ld: fatal: library -lCbcSolver: not found
ld: fatal: library -lCbc: not found
ld: fatal: library -lCgl: not found
ld: fatal: library -lOsiClp: not found
ld: fatal: library -lClp: not found
ld: fatal: library -lOsi: not found
ld: fatal: library -lCoinUtils: not found
ld: fatal: file processing errors. No output written to cbc
collect2: ld returned 1 exit status
-----
However, if I cd into the directory /export/home/locuser/cbc_source/coin-cbc/lib then the libraries do indeed exist there:
-----
-bash-3.2$ cd /export/home/locuser/cbc_source/coin-cbc/lib
-bash-3.2$ ls lib*.so.0
libCbc.so.0 libClp.so.0 libOsiCbc.so.0
libCbcSolver.so.0 libCoinUtils.so.0 libOsiClp.so.0
libCgl.so.0 libOsi.so.0 libOsiCommonTests.so.0
-----
Any ideas on what I am doing wrong here? It seems like there is something non-standard about make on Solaris?