I download and compile openssl 3.0.2 from source and want to link it with libcurl on macOS, however, I encounter some issues, I use latest libcurl 7.82.0.
below is configure.
./configure --prefix="$(pwd)/curl" --with-ssl=/Users/test/Downloads/openssl-openssl-3.0.2/openssl --enable-static --disable-shared --disable-ftp --disable-file --disable-ldap --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-ares --disable-debug --with-zlib=/Users/test/Downloads/zlib-1.2.11/zlib --without-libidn --without-brotli --without-zstd --without-nghttp2 --without-librtmp --without-libidn2 --without-winidn
and configure result looks ok, The openssl include folder is set.
Host setup: x86_64-apple-darwin20.6.0
Install prefix: /Users/test/Downloads/curl-7.82.0/curl
Compiler: gcc
CFLAGS: -Qunused-arguments -Wno-pointer-bool-conversion -Os -Werror=partial-availability -pthread
CPPFLAGS: -isystem /Users/test/Downloads/zlib-1.2.11/zlib/include -isystem /Users/test/Downloads/openssl-openssl-3.0.2/openssl/include -DOPENSSL_SUPPRESS_DEPRECATED
LDFLAGS: -framework CoreFoundation -framework SystemConfiguration -L/Users/test/Downloads/zlib-1.2.11/zlib/lib -L/Users/test/Downloads/openssl-openssl-3.0.2/openssl/lib
LIBS: -lssl -lcrypto -lssl -lcrypto -lz
curl version: 7.82.0
SSL: enabled (OpenSSL v3+)
But when make, it will output error:
Undefined symbols for architecture x86_64:
"_EVP_PKEY_id", referenced from:
_ossl_connect_common in libcurl.a(libcurl_la-openssl.o)
"_SSL_get_peer_certificate", referenced from:
_ossl_connect_common in libcurl.a(libcurl_la-openssl.o)
ld: symbol(s) not found for architecture x86_64
Test:
I found os installed openssl at /usr/local/include/openssl which is 1.1.1m, After I remove this folder, The error is fixed. So I think the system installed openssl header is affected in libcurl make.
I think I have configured libcurl to use /Users/test/Downloads/openssl-openssl-3.0.2/openssl/include, but it does not work.
Thanks in advance.
I have the same problem with openSSL#3. I change to use openssl#1.1/1.1.1s and libcurl and it's working.
Related
I am using ubuntu 16 and installed poco library via apt-get install libpoco-dev (version 1.3).
I also have mysql client installed.
However, when I compile a cpp to test mysql connection, the compiler threw error:
cannot find lPocoDataMySQL
cannot find lPocoJSON
it seems it cannot find the lib for the above two
I have already included the following in Makefile
LD_INCLUDE=-I/usr/include/Poco
CPPFLAGS=-Wno-multichar -Wall -lPocoUtil -lPocoFoundation -lPocoJSON -lPocoNetSSL -lPocoData -lPocoDataMySQL -lPocoJSON
g++ -o dbconnector dbconnector.cpp $(LD_INCLUDE) $(CPPFLAGS)
thanks.
The issue has been resolved by install Poco 1.8.
thanks rafix07
I want to develop a small program that checks which polygons from a shapefile intersect a given rectangle. This program is to be used in a website (with PHP's exec() command). The problem is, my webserver cannot install GDAL, for reasons unknown to me. So I can't link to the shared libraries. Instead, I must link to static libraries, but these aren't given.
I've downloaded the GDAL source code from here (2.3.2 Latest Stable Release - September 2018), and followed the build instructions from here. Since I already have GDAL working on my Debian, and don't want to mess with it, I followed the "Install in non-root directory" instructions, with some adjusts from the last item in the "Some caveats" section:
cd /home/rodrigo/Downloads/gdal232/gdal-2.3.2
mkdir build
./configure --prefix=/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/ --without-ld-shared --disable-shared --enable-static
make
make install
export PATH=/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/bin:$PATH
export LD_LIBRARY_PATH=/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib:$LD_LIBRARY_PATH
export GDAL_DATA=/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/share/gdal
/usr/bin/gdalinfo --version
build/bin/gdalinfo --version
The first /usr/bin/gdalinfo --version gives 2.1.2 (the previous installed version). The second, build/bin/gdalinfo --version, gives 2.3.2 (the version just built).
By now, my program only uses the ogrsf_frmts.h header, which is in /usr/include/gdal/ or /home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/include/ directory, depending on the build. There's no ogrsf_frmts.a file, but only a libgdal.a. Is this the file I should be linking against? If so, how? I've tried so far:
gcc geofragc.cpp -l:libgdal.a
gcc geofragc.cpp -Wl,-Bstatic -l:libgdal.a
gcc geofragc.cpp -Wl,-Bstatic -l:/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
gcc geofragc.cpp -Wl,-Bstatic -l/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
gcc geofragc.cpp /home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
gcc geofragc.cpp -l/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
gcc geofragc.cpp -l:/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
but nothing works. What am I missing?
EDIT
The second trial (gcc geofragc.cpp -Wl,-Bstatic -l:libgdal.a) is giving the following error:
/usr/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-linux-gnu/6/../../../../lib/libgdal.a(gdalclientserver.o): In function `GDALServerSpawnAsync()':
(.text+0x1f5e): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
You can use the gdal-config program to get correct options for compilation and linking. This program is a part of the GDAL library and it has its own options:
hekto#ubuntu:~$ gdal-config --help
Usage: gdal-config [OPTIONS]
Options:
[--prefix[=DIR]]
[--libs]
[--dep-libs]
[--cflags]
[--datadir]
[--version]
[--ogr-enabled]
[--gnm-enabled]
[--formats]
You have to make sure this program is on your search path, or you can create an alias - for example:
alias gdal-config='/home/rodrigo/Downloads/gdal232/gdal-2.3.2/bin/gdal-config'
Now your compilation and linking command becomes the following one:
g++ `gdal-config --cflags` geofragc.cpp `gdal-config --libs` `gdal-config --dep-libs`
You have to use the g++ compiler to link with C++-built libraries.
Another option is to create a Makefile with these lines:
CXXFLAGS += ${shell gdal-config --cflags}
LDLIBS += ${shell gdal-config --libs}
LDLIBS += ${shell gdal-config --dep-libs}
geofragc: geofragc.cpp
and just call make with this Makefile.
I hope, it'll help.
When trying to embed a shared Framework generated from CMake into an Xcode iOS app, I encounter the following issue:
dyld: Library not loaded: /Users/jones/Documents/project/build/ios/foo.framework/foo
Referenced from: /var/Containers/Bundle/Application//myapp.app/myapp
Reason: image not found
It seems like it has an incorrect "dylib id", but I am not sure what that means exactly. Note that my framework appears in the "Frameworks" folder of the app (the built "Product" that is installed on the phone).
Checking my app with otool -L, I see:
myapp:
/Users/name/Documents/project/build/ios/foo.framework/foo
/System/Library/Frameworks/Foundation.framework/Foundation
/usr/lib/libobjc.A.dylib
...
Which seems to show that the path to my framework is wrong in the app. But I can't seem to change it from Xcode.
On the Apple dev forum, somebody mentions changing DYLIB_INSTALL_NAME_BASE to #rpath from Build Settings -> Dynamic Library Install Name Base, but it doesn't solve my problem.
The linker log coming from Xcode looks like so (maybe easier to read here:
Ld /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Products/Debug-iphoneos/myapp.app/myapp normal arm64
cd /Users/jones/Documents/project/ios-playground/myapp
export IPHONEOS_DEPLOYMENT_TARGET=11.2
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk -L/Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Products/Debug-iphoneos -F/Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Products/Debug-iphoneos -F/Users/jones/Documents/project/ios-playground/myapp -F/Users/jones/Documents/project/ios-playground/myapp/Frameworks -filelist /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Intermediates.noindex/myapp.build/Debug-iphoneos/myapp.build/Objects-normal/arm64/myapp.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -miphoneos-version-min=11.2 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Intermediates.noindex/myapp.build/Debug-iphoneos/myapp.build/Objects-normal/arm64/myapp_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fembed-bitcode-marker -stdlib=libc++ -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Xlinker -add_ast_path -Xlinker /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Intermediates.noindex/myapp.build/Debug-iphoneos/myapp.build/Objects-normal/arm64/myapp.swiftmodule -framework foo -Xlinker -dependency_info -Xlinker /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Intermediates.noindex/myapp.build/Debug-iphoneos/myapp.build/Objects-normal/arm64/myapp_dependency_info.dat -o /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Products/Debug-iphoneos/myapp.app/myapp
How can I fix this?
There is actually a way to set the "install_name_dir" in CMake:
set_target_properties(dynamicFramework PROPERTIES
...
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_NAME_DIR #rpath
)
I'm trying to compile the following
#include <GLFW/glfw3.h>
int main()
{
glfwInit();
return 0;
}
just to verify that my GLFW installation is working. I use the terminal with
clang++ -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -I/opt/local/include/ test.c
but I receive a linker error for the glfwInit function:
Undefined symbols for architecture x86_64:
"_glfwInit", referenced from:
_main in test-d8c21e.o
ld: symbol(s) not found for architecture x86_64
I have installed glfw with sudo port install glfw and followed every possible tutorial I've found. I can verify that the libglfw.dylib file can be found at /opt/local/lib/ as (I think) it should.
Any suggestions?
You need to link with GLFW[3] as well, e.g., add:
-L/opt/local/lib -lglfw3
If you have the pkgconfig port installed, you can also take advantage of that with:
clang `pkg-config glfw3 --cflags` test.c -o test \
`pkg-config glfw3 --static --libs`
You may not need the --static flag if you have: libglfw3.dylib, as opposed to using: libglfw3.a, but it doesn't hurt.
If you are using Xcode, you must add the libglfw3.a library when linking binaries.
Heres the trick
Show hidden folders. Paste this into terminal: defaults write com.apple.finder AppleShowAllFiles YES
Relaunch a finder window and navigate to Macintosh HD\usr
Drag the usr folder to the "Favorites" side in the terminal
In xcode, click the add "+" to link binaries, then click "Add Other"
navigate to the libglfw3.a and add it!
If it still does not work, here are some instructions that helped me.
https://engineering-game-dev.com/2013/08/14/glfw-compiling-source-and-creating-an-xcode-project/comment-page-1/#comment-1400
server.cpp - http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/ssl/server.cpp
I am trying to build this on my mac. Using the following. (builds fine on my ubuntu system)
g++ -I /usr/local/boost/ sslserver.cpp -o sslserver -lboost_system -lssl -lpthread
My libs are located in /usr/local/lib so I tried adding -L /usr/local/lib after the includes. However, I have built other projects before using -lboost_system -lpthread without any issues or specifying the libs.
The error is huge > https://dl.dropbox.com/u/15586644/error.txt
Its mainly lots of deprecated methods warnings - I doubt anything is deprecated.
followed by Undefined symbols for architecture x86_64.
How should I go about building server.cpp on MacOSX?
See
- Why is Apple Deprecating OpenSSL in MacOS 10.7 (Lion)?
Apple is migrating from OpenSSL to Common Crypto, hence depreciated warnings