xcode


Link dylib library


I'm trying to link a dylib to my makefile on Mac, but Clang gives this message:
Undefined symbols for architecture x86_64:
"_zbesj_wrap", referenced from:
sp_bessel::besselJ(double, std::__1::complex<double>) in besselJ.o
"_zbesy_wrap", referenced from:
sp_bessel::besselJ(double, std::__1::complex<double>) in besselJ.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I installed the library in /usr/lib, where I can see libcomplex_bessel.0.6.0.dylib and libcomplex_bessel.dylib.
This is my makefile:
OBJS = main.o besselJ.o
CC = c++
CFLAGS = -std=c++11 -stdlib=libc++
LIBS = -L/usr/lib -lcomplex_bessel
PROGRAM_NAME = test
all: $(PROGRAM_NAME)
$(PROGRAM_NAME): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $#
main.o: main.cpp
$(CC) $(CFLAGS) -c $< -o $#
besselJ.o: besselJ.cpp
$(CC) $(CFLAGS) -c $< -o $# $(LIBS)
After reading other questions, I tried different combinations for -L and -l but nothing worked. Sorry but it's my first time with external libraries...
I changed my makefile to this:
OBJS = main.o besselJ.o
CC = c++
CFLAGS = -std=c++11 -stdlib=libc++
LIBS = -L/usr/lib -lcomplex_bessel
PROGRAM_NAME = test
all: $(PROGRAM_NAME)
$(PROGRAM_NAME): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $# $(LIBS)
main.o: main.cpp
$(CC) $(CFLAGS) -c $< -o $#
besselJ.o: besselJ.cpp
$(CC) $(CFLAGS) -c $< -o $#
but I still have problems, I get this message:
c++ -std=c++11 -stdlib=libc++ main.o besselJ.o -o test -L/usr/lib -lcomplex_bessel
ld: library not found for -lcomplex_bessel
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test] Error 1
Ok, I think I solved it using xcode-select --install: other users had the same problem with libraries after updating it.
You need to pass libs to linker, not to the compiler:
OBJS = main.o besselJ.o
CC = c++
CFLAGS = -std=c++11 -stdlib=libc++
LIBS = -L/usr/lib -lcomplex_bessel
PROGRAM_NAME = test
all: $(PROGRAM_NAME)
$(PROGRAM_NAME): $(OBJS)
$(CC) $(OBJS) -o $# $(LIBS)
main.o: main.cpp
$(CC) $(CFLAGS) -c $< -o $#
besselJ.o: besselJ.cpp
$(CC) $(CFLAGS) -c $< -o $#

Related Links

How can I change the Xcode 6 Device screenshot destination?
UIPickerView throws -[__NSArrayM objectAtIndex:]: index 0 beyond bounds when data source is not empty in iOS 8
SWRevealViewController push Segue
Responding to tilt of iPhone in Sprite Kit
Archive validation failed with errors
Trouble with the libPng.dylib from freetype 2.5.3
xcode 5 auto layout - view stretches, but not the view's contents
upgraded xcode to 5.1.1 broke CocosDenshion
Error E175013 by using SVN over XCode 6 (OSX 10.9)
xcodebuild - codesign -vvvv says“resource envelope is obsolete”
Including Bullet Physics in Xcode Project for OS X
ERROR ITMS-9000 xcode app submission error
Gradually move from one color to another
Localisation English appears double
am I safe to upgrade my cocos2d 2.1 game to XCode 6 to support iPhone 6?
Use Scaling Rather Than Native Resolution - Xcode 6

Categories

HOME
hpoo
jboss
entity-framework
magento2
facebook-messenger
yii
long-integer
scroll
message-queue
plpgsql
whmcs
yql
mathematical-optimization
elisp
fogbugz
greasemonkey
mosquitto
azure-data-lake
turbojpeg
scheduler
elastic-load-balancer
spring-security-oauth2
lc3
documentum
clish
sonicwall
synthesis
web-deployment
exec-maven-plugin
gmp
multiple-tables
cmake-gui
gitkraken
sharedpreferences
gollum-wiki
mime-types
candlestick-chart
backendless
restier
prompt
uri
android-service
network-analysis
sendmessage
es6-modules
matlab-app-designer
infopath2010
windows2012
commonsware-cwac
rust-cargo
winrm
adminer
java-stream
char-pointer
android-n
reset
microkernel
vb.net-to-c#
pyttsx
dbcc
asihttprequest
wysihtml5
swift2.3
jgrapht
sharpdx
mongodb-aggregation
gmaps.js
fuzzer
visual-studio-monaco
nvda
oci
mathnet
currency-exchange-rates
ioctl
opencyc
apple
wlanapi
dynamics-ax-2012-r2
android-handler
web-api
createfile
directorysearcher
password-recovery
image-rotation
iplimage
xcode6.3.1
category-theory
thruway
apache-shindig
form-for
aero
oembed
ip-geolocation
gitx
coordinate
image-scanner
nosetests
page-curl
canonicalization
grails-validation
cassini
activestate
yahoo-maps
ppc
tso
motif
prism-2
remote-working

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App