Reputation: 2839
Few days ago I downloaded clion to make a school project in C++ and Allegro5. First I used allegro installed with homebrew but it wasn't working so I compiled it by myself. Since I've never worked with CMake before it took me some time to include the libs and compile the project but I managed to do it. The problem is that when I try to run it it throws an error:
dyld: Symbol not found: __al_mangled_main
Referenced from: /usr/local/lib/liballegro_main.5.0.dylib
Expected in: flat namespace
in /usr/local/lib/liballegro_main.5.0.dylib
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.3)
project(arkanoid)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES classes/main.cpp classes/ball.cpp classes/ball.h classes/block.cpp classes/block.h)
add_executable(arkanoid ${SOURCE_FILES})
INCLUDE_DIRECTORIES( allegro/5.0.11/include )
LINK_DIRECTORIES( allegro/5.0.11/lib )
TARGET_LINK_LIBRARIES(arkanoid allegro_acodec
allegro_audio
allegro_color
allegro_dialog
allegro_image
allegro_main
allegro_memfile
allegro_physfs
allegro_primitives
allegro_ttf
allegro_font
allegro)
And for now my main.cpp looks like this:
#include <iostream>
#include <allegro5/allegro.h>
using namespace std;
int main() {
al_init();
return 0;
}
I'm trying to build this project on OSX. I've searched for 2 days for the solution to my problem but with no results. Not many people are using CLion and even less use it with allegro5. Could anyone have a clue what this error even mean?
Upvotes: 2
Views: 1255
Reputation: 2839
Ok this one blew my mind. I don't know why I found solution only after asking on stackoverflow but I'm posting it for someone who might encounter simillar problem to mine. Change your main declaration from
int main()
to
int main(int argc, char **argv)
and that's it. Really.
Upvotes: 3