I have an Altera Cyclone V SoC DevKit that came with the ARM DS-5 tools. I have been running the Hello World C linux app examples that came with the tools. I want to run a similar C++ linux app example, so I copied the C example project (as I have several times before) but this time renamed the main.c file as main.cpp. Everything compiled okay. Then I added #include <iostreams> and the build broke.
**** Build of configuration Default for project helloCpp ****
make all
if not exist stripped mkdir stripped
arm-linux-gnueabihf-gcc main.o -o hellocpp -marm -march=armv4t -mfloat-abi=soft
main.o: In function `__static_initialization_and_destruction_0':
c:\altera\13.1\embedded\ds-5\sw\gcc\bin\../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/include/c++/4.7.3/iostream:75: undefined reference to `std::ios_base::Init::Init()'
main.o: In function `_GLOBAL__sub_I_main':
C:\Dev\DS-5 Workspace\helloCpp/main.cpp:23: undefined reference to `std::ios_base::Init::~Init()'
collect2.exe: error: ld returned 1 exit status
make: *** [hellocpp] Error 1
**** Build Finished ****
I've attached the main.cpp and the makefile. The makefile I hardwired the main.o target, and disabled the $(OBJS) targets, to force usage of the C++ compiler. Otherwise the makefile is what I found in the \hello example project.
My first suspicion is that there is an #include path issue. I had already added all the #include paths I found in the \gnometris project, which was the only C++ example project I could find. Is there one missing?
Second suspicion is a library path issue. However, I noted the \gnometris project did not specify any libraries. What libraries should be included for this?
Third (actually the strongest suspicion) there is something wrong with the makefile. Is there a simple C++ example project that will compile with the Cyclone V DS-5 tools?
Thanks
It's issue with the Makefile, to be more specific the way you are compiling main.o into hellocpp
This has nothing to do with ARM DS5 as you are using GCC toolchain which is part of it.
The issue is here:
Instead
arm-linux-gnueabihf-c++/g++ main.o -o hellocpp -marm -march=armv4t -mfloat-abi=soft
will work.
Change in Makefile:
$(TARGET): $(OBJS)
$(call MD,$(STRIPPED_DIR))
$(CC) $(OBJS) -o $(TARGET) $(ABI)
$(STRIP_APP) $(TARGET) -o $(STRIPPED_DIR)/$(TARGET)
to
$(CPP) $(OBJS) -o $(TARGET) $(ABI)
Sudeep Holla -
Tried the fix - it worked. Thank you very much.