Pergunta

I have a Xilinx FPGA running a soft processor (PowerPC). I recently cross compiled Boost libraries for PowerPC and wanted to test it. So I used one of the sample programs and tried to cross compile it for my target. Below is the code

#include <boost/thread/thread.hpp>

void helloworld()
{
   printf( "Hello World!");
}

int main()
{
    boost::thread thrd(&helloworld);
    thrd.join();
}

Below is my make file

CPP=ppc_4xx-g++
CFLAGS=-c -g -Wall
LDFLAGS_PowerPC=-L/shared/deps/powerpc/lib -L/opt/ELDK/4.2/ppc_4xx/lib/
LIBS_PowerPC=-lboost_thread -lboost_system -lpthread -lrt
INCLUDES=-I. -I./4.2.2/ -I./include -I/opt/ELDK/4.2/ppc_4xx/usr/include/
CPPFLAGS_PowerPC=-I/shared/deps/common/include
CPPFLAGS_COMMON=-I/shared/deps/powerpc/include
CPPFLAGS=$(CPPFLAGS_COMMON) $(CPPFLAGS_PowerPC)

all: helloworld

helloworld: helloworld.o
    $(CPP) $(LDFLAGS_PowerPC) $(LIBS_PowerPC) helloworld.o -o helloworld

helloworld.o: helloworld.cpp
    $(CPP) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) helloworld.cpp
clean:
    rm -rf *.o helloWorld

I was able to generate the binaries but when I run the program on my target I get the below error

-/bin/sh: ./helloworld: not found

I checked online and found that the above problem comes when we have dynamic linking. My Boost libraries are present in the location /shared/deps/powerpc/lib and I have set the variable LD_LIBRARY_PATH accordingly using the below command.

export LD_LIBRARY_PATH=/shared/deps/powerpc/lib/:/opt/ELDK/4.2/ppc_4xx/lib/

But even then I get the same problem.

Below is the output of uname -ars

Linux (none) 3.0.0-14.1-build3+ #23 PREEMPT Thu Jan 3 18:44:27 CST 2013 ppc GNU/Linux

I don't have ldd installed on my target so I can't check the dynamic dependencies. But I am sure that, libraries are included. How can I proceed ?

Foi útil?

Solução

Even though my embedded Linux system had a dynamic linker, it was not working. The problem was resolved when I used a dynamic linker provided with my tool chain and replaced it the correct directory. Now dynamic linking is fine.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top