Failed to link program with OpenSSL - gcc

This is my compile command
gcc msg_utils.o -o mtm -lm -L/openssl-1.0.0a -lssl -lcrypto
I get error :
/usr/bin/ld: cannot find -lssl
Please tell me what wrong with my command ,the path to openssl is correct ,I get openssl source from :
https://www.openssl.org/source/openssl-1.0.0a.tar.gz

(I guess you are on Linux)
You should probably install some OpenSSL package in your Linux distribution.
Perhaps aptitude install libssl-dev on Debian related distributions.
If you compile OpenSSL from source code, you probably need some make install step and you might need to run ldconfig after that.
You might want to use pkg-config during compilation of your code:
gcc -Wall -g $(pkg-config -cflags openssl) \
msg_utils.o -o mtm \
$(pkg-config -libs openssl)
See also this and that

Related

Compiling my program with OpenSSL as static library on windows fail

I wrote a program that is using OpenSSL and I'm trying to compile it to executable for inwdows.
The command I'm using to compile is:
gcc -g -Ifolder1/include -Iopenssl/include -Ifolder2 -c folder1/lib/functions.c -o folder1/lib/functions.o
gcc -g -Ifolder1/include -Iopenssl/include -Ifolder2 -o myprog.exe main.o folder1/lib/myfiles.o folder1/lib/plus.o folder1/lib/functions.o -Lopenssl/windows/static -lcrypto
This works for linux but for windows i get
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lcrypto
Any idea what is the corresponding flag for -lcrypto for linux?
The problem was that in path openssl/windows/static i had a library with the suffix *.lib and seems like gcc doesnt recongnize it as a library.
resolved when i change it to *.a suffix

configure: error: one or more libs available at link-time are not available run-time. Libs used at link-time: -lssh2 -lssl -lcrypto -lz

env: centos7
install curl
when i start install curl and ./configure --with-ssl --with-zlib, i occurs errors about libs, what mean about link-time? it's env set? i have no any experience about installtaion by make, needed to install other package? how to fix it?
./configrue --with-ssl --with-zlib
accurs errors:
checking run-time libs availability... failed
configure: error: one or more libs available at link-time are not available
run-time. Libs used at link-time: -lssh2 -lssl -lcrypto -lz
the errors occur bebause of openssl install
after installed openssl, should check up while it usefully
when i input openssl version, it show same unkown path errors
so, u should set:
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
it worked!
You can also add LD_LIBRARY_PATH in front of the configure script:
LD_LIBRARY_PATH=/usr/local/lib64 ./configure --with-ssl --with-zlib

rJava on MacOS Sierra 10.12.15: unsupported option fopenmp

I'm trying to install rJava on MacOS Sierra. Have to tried the tips and guides elsewhere for other other version MacOS such as https://github.com/snowflakedb/dplyr-snowflakedb/wiki/Configuring-R-rJava-RJDBC-on-Mac-OS-X
and Install xlsx and rJava on Mac
but it does not work out. Much appreciate any help. Thanks.
My Mac version: macOS Sierra, version 10.12.15
My R version: 3.4.0 (2017-04-21)
My Rstudio version: Version 0.99.903
Java version:
bash-3.2$ /usr/libexec/java_home -V
bash-3.2$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
bash-3.2$ R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.8.0_131
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Non-system Java on macOS
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -fPIC -Wall -g -O2 -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /Library/Frameworks/R.framework/Resources
override rw-r--r-- root/admin for /Library/Frameworks/R.framework/Resources/etc/Makeconf? (y/n [n]) n
not overwritten
override rw-r--r-- root/admin for /Library/Frameworks/R.framework/Resources/etc/ldpaths? (y/n [n]) n
not overwritten
Done.
When I tried to install rJava, I ran
`R --quiet -e 'install.packages("rJava", type="source", repos="http://cran.us.r-project.org")`
I got the errors:
clang: error: unsupported option '-fopenmp'
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
The downloaded source packages are in
‘/private/var/folders/w8/ksbj8dh15bz2lkss7h2tpzk80000gn/T/Rtmp6r9HI0/downloaded_packages’
Warning message:
In install.packages("rJava", type = "source", repos = "http://cran.us.r-project.org") :
installation of package ‘rJava’ had non-zero exit status
I ran:
"curl -#ROL https://www.rforge.net/rJava/snapshot/rJava_0.9-8.tar.gz
R CMD INSTALL rJava_0.9-8.tar.gz"
and got the following error messages:
clang: error: unsupported option '-fopenmp'
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
I dont know what to do. Thanks for your help.
This article here solved this fopenmp issue for me on macOS Sierra 10.12.4. I outlined the solution here but also below. The problem is that forenmp option is not supported in macOS gcc so we have to compile a new version of the gcc.
Solution to forenmp problem
I have tested this with Homerew's r-app brew cask install r-app and Oracle's JDK. Then I did the following
brew install homebrew/versions/gcc49 --without-multilib #Long ~70min compiling...
sudo chown -R $(whoami):admin /usr/local
brew link --overwrite --force gcc49
brew unlink gcc49 && brew link gcc49
brew install llvm
mkdir ~/.R; touch ~/.R/Makevars
echo "VER=-4.9
CC=gcc$(VER)
CXX=g++$(VER)
CXX1X=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc/4.9.3/lib/gcc/4.9" > ~/.R/Makevars
and now
sudo R CMD javareconf
Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
and now rJava is working!
Comments using OSX 10.12.6 with Java 1.8.0_181 and dealing with the above issue and another issue related to compiling rJava.
First:
Install rJava with these commands:
wget https://cran.r-project.org/src/contrib/rJava_0.9-10.tar.gz
tar xvfz rJava_0.9-10.tar.gz
cd rJava
R CMD INSTALL rJava
Why use R CMD INSTALL? This will keep the config.log file that will allow you to debug things; install.packages() does not and help you get might not be very helpful in that case (e.g. https://github.com/s-u/rJava/issues/111).
Second:
Make sure you run the following, if you've updated Java (remember you need the JDK, not JRE).
sudo R CMD javareconf
Error (checking JNI data types):
To fix this error:
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
do this:
sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
sudo ln -f -s /usr/local/lib/libjvm.dylib /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/
Error (unsupported option '-fopenmp):
To fix this error:
clang: error: unsupported option '-fopenmp
do the following:
Note: The instructions may need to be modified for newer versions of gcc, but make sure you get a version greater than 7 (see notes that follow); the following command can be used to find out the available versions:
brew search gcc
Then install gcc:
brew install gcc#7
sudo chown -R $(whoami):admin /usr/local
brew link --overwrite --force gcc#7
brew unlink gcc#7 && brew link gcc#7
brew install llvm
mkdir -p ~/.R
## Check the versions and folder in FLIBS match what you install
echo "CC=gcc-7
CXX=g++-7
CXX1X=g++-7
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc\#7/7.3.0/lib/gcc/7" > ~/.R/Makevars
Notes: You need any version of gcc greater than 7; the without-multilib flag mentioned in the earlier answer may not be available, but it is important. Why the without-multilib flag?: https://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/ and OpenMP/gcc on macOS : gcc --without-multilib not available
Then install rJava
R CMD INSTALL rJava
Finally, test library (you should see your Java version):
library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
Take a look here:
http://www.owsiak.org/?p=3671
You can find quite detailed description of how to deal with rJava in macOS.
Make sure to install JDK that is provided by Oracle before you proceed.

How to install PyGSL? (Windows 7, 64 bit, Python 2.7, GSL 1.15)

I'm trying to install PyGSL on my computer (64 bit Windows 7), with Python 2.7 and GSL 1.15 installed. I'm pretty much stuck and I would love for some extra help. GSL installed fine, but its the wrapper that's the problem. For some reason I can't build pygsl. Apparently gcc is the problem (got the same problem on another windows machine). Or it could be that pygsl appears to be using a file named AMD64 while my computer is x86. I would love to use the windows binary for pygsl, but it only exists for python 2.5, and my project needs 2.6 or higher. I've used both the windows binary for GSL and built it from source, but I get the same problem either way. I tried copying dlls from GSL into pygsl but that didn't work. Some forums mentioned a file called gsl.dll but I can't seem to find it. I've also tried to use Cygwin and to compile with minGW32 to no avail.
cmds I ran:
python setup.py install
python setup.py build
python setup.py build_ext -i
python setup.py build --compiler=mingw32
Any ideas?? Thanks.
Cheers,
Bereket
Got the same message in Cygwin as in the windows cmd prompt. Error message:
$ /cygdrive/c/Python27/python.exe setup.py build_ext -i
numpy
Forcing DISTUTILS_USE_SDK=1
Building testing ufuncs!
running build_ext
building 'errno' extension
C compiler: gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wall -Wstrict-prototypes
compile options: '-DSWIG_COBJECT_TYPES=1 -DGSL_RANGE_CHECK=1 -DDEBUG=1 -DNUMERIC=0 -DPYGSL_GSL_MAJOR_VERSION=1 -DPYGSL_GSL_MINOR_VERSION=15 -UNDEBUG -IC:\Users\Bereket\gsl-1.15\include -IInclude -I. -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c'
gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wall -Wstrict-prototypes -DSWIG_COBJECT_TYPES=1 -DGSL_RANGE_CHECK=1 -DDEBUG=1 -DNUMERIC=0 -DPYGSL_GSL_MAJOR_VERSION=1 -DPYGSL_GSL_MINOR_VERSION=15 -UNDEBUG -IC:\Users\Bereket\gsl-1.15\include -IInclude -I. -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c src/init/errorno.c -o build\temp.win-amd64-2.7\Release\src\init\errorno.o
Found executable C:\cygwin\bin\gcc.exe
gcc -g -mno-cygwin -shared build\temp.win-amd64-2.7\Release\src\init\errorno.o -LC:\Users\Bereket\gsl-1.15\lib -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -lgsl -lgslcblas -lm -lpython27 -lmsvcr90 -o C:\Python27\Lib\pygsl-0.9.5\pygsl\errno.pyd
build\temp.win-amd64-2.7\Release\src\init\errorno.o: In function `add_errno':
/cygdrive/c/Python27/Lib/pygsl-0.9.5/src/init/errorno.c:14: undefined reference to `__imp__PyInt_FromLong'
/cygdrive/c/Python27/Lib/pygsl-0.9.5/src/init/errorno.c:20: undefined reference to `__imp__PyDict_SetItemString'
build\temp.win-amd64-2.7\Release\src\init\errorno.o: In function `initerrno':
/cygdrive/c/Python27/Lib/pygsl-0.9.5/src/init/errorno.c:37: undefined reference to `__imp__Py_InitModule4_64'
/cygdrive/c/Python27/Lib/pygsl-0.9.5/src/init/errorno.c:40: undefined reference to `__imp__PyModule_GetDict'
collect2: ld returned 1 exit status
error: Command "gcc -g -mno-cygwin -shared build\temp.win-amd64-2.7\Release\src\init\errorno.o -LC:\Users\Bereket\gsl-1.15\lib -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -lgsl -lgslcblas -lm -lpython27 -lmsvcr90 -o C:\Python27\Lib\pygsl-0.9.5\pygsl\errno.pyd" failed with exit status 1
I'm pretty sure now that my GSL install with Cygwin failed / had unresolved dependencies. I'm now trying to install it with visual studio 2010. Here are some good sites for doing that:
Instructions
Alt Method
Installing the Python 2.7 compiler for Windows is a good place to start
http://www.microsoft.com/en-gb/download/details.aspx?id=44266
Running python setup.py build_ext --inplace does the trick for me.
If this doesn't work let me know. You might need to add an environment variable.
Is your Python 32 or 64? To check open Python and do
import sys
sys.versions

mountainlion apr compile lacking 'cc'

Trying to build mod_auth_openid on MountainLion with XCode Version 4.4.1 (4F1003), I get a complaint about a missing 'cc' command, as follows:
/usr/share/apr-1/build-1/libtool --silent --mode=link /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -o mod_auth_openid.la -rpath /usr/libexec/apache2 -module -avoid-version libmodauthopenid.la -I/usr/include/apache2 -I/usr/include/apr-1 -I/usr/local/include -L/usr/local/lib -lopkele -lcurl -lexpat -ltidy -lssl -lcrypto -lz -L/usr/lib -lpcre -lcurl
/usr/share/apr-1/build-1/libtool: line 4574: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
apxs:Error: Command failed with rc=8323072
What to do?
I faced a similar problem while trying to install mod_wsgi using homebrew on Mac (Mountain Lion).
Though bmargulies posted the answer in his comment by pointing to github link. But still posting the solution here for completeness.
Run the following command.
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain
And then re-run the install command
Ran into exactly this problem with Mountain Lion/Homebrew/mod_wsgi. The toolchain symlink did not solve the problem in my case. Went back to another Mac where I used MacPorts to do this with no issues and looked at the Portfile for mod_wsgi. They had a --disable-framework flag in the configure step. Added this flag and everything worked great. Details available in the gist here https://gist.github.com/talonsensei/6284446

Resources