creating dynamic libraries on MAC

Joined
Apr 13, 2011
Messages
2
Reaction score
0
Points
1
Hi,

I have to create two dynamic libraries from two projects 'basic' and 'lia', where lia depends upon basic. I have created and used both successfully on linux, but when I try to compile the same on mac it creates an issue.

--------- Linux
Here are the commands that my makefile generates

g++ -m64 -Wl,-O1 -shared -o libbasic.so obj/arg.o obj/basic.o obj/cb.o obj/cb_doprnt.o obj/counter.o obj/files.o obj/getarg.o obj/isort.o obj/istaque.o obj/malloc.o obj/math2.o obj/prime.o obj/qsort.o obj/time.o obj/tokenize.o obj/uhash.o -L/usr/lib64 -lQtGui -L/usr/lib64 -L/usr/X11R6/lib64 -pthread -lpng -lfreetype -lSM -lICE -pthread -pthread -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
mv -f libbasic.so ../lib.linux64/

g++ -m64 -Wl,-O1 -shared -o liblia.so obj/aux.o obj/chars.o obj/det.o obj/lia.o obj/pool.o obj/stack.o obj/test.o -L/usr/lib64 -lQtGui -L/usr/lib64 -L/usr/X11R6/lib64 -pthread -lpng -lfreetype -lSM -lICE -pthread -pthread -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
mv -f liblia.so ../lib.linux64/

-------------- MAC

When I try to compile on mac, basic goes fine. But in linking of lia, it throws a linking error.

g++ -headerpad_max_install_names -single_module -dynamiclib -o liblia.dylib obj/aux.o obj/chars.o obj/det.o obj/lia.o obj/pool.o obj/stack.o obj/test.o -F/Library/Frameworks -L/Library/Frameworks -framework QtGui -framework QtCore
Undefined symbols:
"_basic_error", referenced from:
_lia_maximum in aux.o
...
_test1 in test.o
"_basic_ipower", referenced from:
_lia_ffpload in aux.o
"_basic_malloc", referenced from:
_lia_strload in aux.o
...
_lia_push in stack.o
"_basic_strip", referenced from:
_main in test.o
..... (and many more)

Thus, all the functions in 'basic' go unlinked. Could someone illuminate the difference between linux and max wrt this ? Why do i need 'basic' lib to create 'lia' lib on mac ?
 
OP
B
Joined
Apr 13, 2011
Messages
2
Reaction score
0
Points
1
Also, if I try to build these libraries as static libs, both 'basic' and 'lia' are built successfully. I dont understand how dynamic linking works on mac.
 
Joined
Jun 17, 2011
Messages
1
Reaction score
0
Points
1
Hi

I am stuck on same point however I did not try static building, have u find a solution about dynamic building u mentioned
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top