Allegro library with Code Blocks mac osx - macos

spent some time, with the big help of other SO user, trying to install Allegro library on osx 10.10.5
Finally it seems like it is ok, so I open the code blocks, pasted the example code( http://partitionseven.blogspot.com/2011/01/compiling-allegro-5-with-mac-os-x-snow.html), and I get an error while copiling
g++ -c /Users/lukasz/Desktop/test_allegro/test.cpp -o /Users/lukasz/Desktop/test_allegro/test.o
g++ -o /Users/lukasz/Desktop/test_allegro/test /Users/lukasz/Desktop/test_allegro/test.o
Undefined symbols for architecture x86_64:
"_al_clear_to_color", referenced from:
__al_mangled_main in test.o
"_al_create_display", referenced from:
__al_mangled_main in test.o
"_al_destroy_display", referenced from:
__al_mangled_main in test.o
"_al_flip_display", referenced from:
__al_mangled_main in test.o
"_al_install_system", referenced from:
__al_mangled_main in test.o
"_al_map_rgb", referenced from:
__al_mangled_main in test.o
"_al_rest", referenced from:
__al_mangled_main in test.o
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: __al_mangled_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
when I follow the tutorial exactly running the code from terminal with
gcc alleg5test.c -o alleg5test -L/usr/local/lib -lallegro -lallegro_main
./alleg5test
it works- i got a black screen. But how do I make it work from Code Blocks?

Related

Compile Fortran Function using gfortran: object file was built for newer macOS version than being linked

Given a very simple fortran (95) function and a very simple c++ call to the program, I should be able to compile the program using:
g++ -c main1.cpp
gfortran -c test.f95
g++ main1.o test.o -o run
However, here I get the following error:
ld: warning: object file (test.o) was built for newer macOS version (11.5) than being linked (11.0)
Undefined symbols for architecture arm64:
"hello_()", referenced from:
_main in main1.o
"__gfortran_st_write", referenced from:
_hello_ in test.o
"__gfortran_st_write_done", referenced from:
_hello_ in test.o
"__gfortran_transfer_character_write", referenced from:
hello in test.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here, adding a -v tag before the -o tag and after the -o tag and the exe run did not solve the problem, as suggested by the error message.

httpd(2.4.25), openssl(1.0.2k) - Cannot compile in macOS Sierra Error on make: Undefined symbols for architecture x86_64: "_CRYPTO_malloc_init"

Operating system is macOS Sierra, osx 10.12.3
Configure command line:
./configure --prefix=/usr/local/mac-dev-env/apache-2.4.25 --enable-so --enable-ssl --with-ssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
Error created by make:
/usr/local/apr-1.5.2/build-1/libtool --silent --mode=link gcc -g -O2
-L/usr/local/mac-dev-env/openssl-1.0.2k/lib -lssl -lcrypto -lpthread \
-o ab ab.lo /usr/local/apr-util-1.5.4/lib/libaprutil-1.la -lexpat -liconv /usr/local/apr-1.5.2/lib/libapr-1.la -lpthread Undefined symbols for architecture x86_64: "_CRYPTO_malloc_init", referenced from:
_main in ab.o "_OPENSSL_init_ssl", referenced from:
_main in ab.o "_OPENSSL_sk_num", referenced from:
_ssl_proceed_handshake in ab.o "_OPENSSL_sk_value", referenced from:
_ssl_proceed_handshake in ab.o "_SSL_CTX_set_options", referenced from:
_main in ab.o "_SSL_in_init", referenced from:
_main in ab.o
_ssl_state_cb in ab.o "_TLS_client_method", referenced from:
_main in ab.o "_X509_get_version", referenced from:
_ssl_print_cert_info in ab.o "_X509_getm_notAfter", referenced from:
_ssl_print_cert_info in ab.o "_X509_getm_notBefore", referenced from:
_ssl_print_cert_info in ab.o ld: symbol(s) not found for architecture x86_64
I went to http://www.linuxfromscratch.org/blfs/view/svn/server/apache.html
From there I found two dependencies Apr-Util-1.5.4 and PCRE-8.40.
I configure the build of apr-util with:
./configure --prefix=/usr/local/mac-dev-env/apr-util-1.5.4 --with-apr=/usr/local/mac-dev-env/apr-1.5.2 --with-openssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-crypto
Most important was to build apr-util with --with-openssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-crypto.
I then built pcre-8.40 as I had been attempting to build with pcre-8.39.
I believe the root cause was not building with apr-util-1.5.4 with the --with-openssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-crypto options.
My configuration before make for apache-2.4.25 was:
./configure --prefix=/usr/local/mac-dev-env/apache-2.4.25 --enable-so --enable-ssl --with-ssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-apr=/usr/local/apr --with-apr-util=/usr/local/mac-dev-env/apr-util-1.5.4 --with-ldap

How do I solve the following linker error with my OpenGL program in Xcode?

I am getting the following errors when I try to compile my C++ OpenGL program in Xcode on Mac OS 10.8...What should I do?
Undefined symbols for architecture x86_64:
"_aglChoosePixelFormat", referenced from:
_main in main.o
"_aglCreateContext", referenced from:
_main in main.o
"_aglDestroyContext", referenced from:
_main in main.o
"_aglDestroyPixelFormat", referenced from:
_main in main.o
"_aglSetCurrentContext", referenced from:
_main in main.o
"_aglSetFullScreen", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Since you're using AGL, looking at the reference for AGL, you need to import the framework AGL along with OpenGL.

gmp-chudnovsky.c and xcode 4.5

when I try to compile and run the gmp-chudnovsky.c file found here with xcode the following errors appear:
Undefined symbols for architecture x86_64:
"_fac_clear", referenced from:
_main in main.o
"_fac_compact", referenced from:
_fac_remove_gcd in main.o
"_fac_init", referenced from:
_main in main.o
"_fac_mul", referenced from:
_bs in main.o
"_fac_mul_bp", referenced from:
_bs in main.o
"_fac_resize", referenced from:
_fac_remove_gcd in main.o
"_fac_set_bp", referenced from:
_bs in main.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 know the gmp library is installed correctly as I have another xcode project linking to it that is compiling correctly. Any ideas as to why this is happening?
Forgot to say I have added paths to the header file and library for GMP as well as add the -lgmp flag under Other Linker Flags
SOLVED: see this answer.
I think xcode runs in a Debug configuration first, where no optimization is performed and no inlining is carried out. This means any inline function must also be made static.

Compiling C/C++ application using SDL in OS X, linking problem

I'm trying to compile a C/C++ program that uses SDL on a OS X 10.6.8 but I'm having some errors on the linking stage, the code compiles but fails to like due to some missing symbols. The error is:
Undefined symbols for architecture x86_64:
"_CFBundleGetMainBundle", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
_main in libSDLmain.a(SDLMain.o)
"_CFBundleCopyBundleURL", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLCreateCopyDeletingLastPathComponent", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLGetFileSystemRepresentation", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFRelease", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
...
"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
objc-class-ref in libSDLmain.a(SDLMain.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [dist/linwarrior] Error 1
I checked with the file command and the libraries are either x86_64 only or universal with both i386 and x86_64 versions.
Is there a way for me to determine what exactly is causing this error? A way to check the libs that are being included or any way to help debug the problem?
I don't know if it helps but this is what my Makefile creates, I removed file names to make it short, and the KNT flag is just something I'm using for preprocessor conditions:
/opt/local/bin/g++-mp-4.5 -DKNT=1 -Wp,-M,-MP,-MT,-MF, -std=c++0x -Wall -I source -O1 -funroll-loops -c -o
Thanks.

Resources