jenswi-linaro / lcu14_optee_hello_world

22 stars 16 forks source link

'/usr/bin/ld: cannot find -lteec' #17

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello, I'm trying to build the 'Hello world' example and I'm getting this error:

issue

I tried to change the makefile, move the lib path and many many more but nothing worked.

I've checked all the Issues board (and OP-TEE too) but nothing worked for me :(

Can anyone help me please?

Thanks in advance.

vchong commented 8 years ago

The required variables are not defined. Have you run all the previous instructions first?

First build the OP-TEE software stack.

Then define the following variables: If normal world user space is 64-bit: export HOST_CROSS_COMPILE=$PWD/../toolchains/aarch64/bin/aarch64-linux-gnu- If normal world user space is 32-bit: export HOST_CROSS_COMPILE=$PWD/../toolchains/aarch32/bin/arm-linux-gnueabihf-

Then: export TA_CROSS_COMPILE=$PWD/../toolchains/aarch32/bin/arm-linux-gnueabihf- export TEEC_EXPORT=$PWD/../optee_client/out/export export TA_DEV_KIT_DIR=$PWD/../optee_os/out/arm/export-ta_arm32

Then: make

sudo is not required.

ghost commented 8 years ago

Yes, I did. I think my normal world user space is 32-bit, is there any way to check that?

If I do a make without sudo this is the output I get:

issue2

vchong commented 8 years ago

It's the normal world user space for your target board, not your pc. Which target platform are you trying to build this for? That would tell you whether you need 32 or 64.

Now the variables are defined, but the toolchain is missing. Did you not already succeeded in running 'make toolchains' previously in another post? Did you get rid of them?

ghost commented 8 years ago

I'm building this for the qemu emulator, don't know well if this is the target board you're referring to.

I though toolchains building gone well, but I just built it again and not, it gets me this error:

issue3

vchong commented 8 years ago

For qemu, it's 32-bit, so you need: export HOST_CROSS_COMPILE=$PWD/../toolchains/aarch32/bin/arm-linux-gnueabihf-

If you failed to 'make toolchains', then how did you manage to build the OP-TEE software stack (step 2 of the instructions)? You can't start building this hello world without having the stack first.

What is the file size of the gcc-linaro-arm-linux-gnueabihf-4.9-2014.08_linux.tar.xz file you downloaded? Are you behind a company or personal firewall? Can you try downloading the file manually and extracting it to the proper location?

ghost commented 8 years ago

Well, the OP-TEE software stack is built because a Linaro worker gave me a virtual machine with the created environment. Qemu is working as long as I do a 'make all run' in the build path and it builds the normal and secure world. The problem is only building the 'Hello world' example.

I'm behind a proxy, that was the problem why toolchains doesn't build, but I've just connected by my 4G phone connection and the toolchains build has been succesfull. However the error I've posted in the last message keeps running yet:

issue2

The size of the file that you told me is 50,6 MB. I've not tried to download the file manually, but i can do it now.

vchong commented 8 years ago

Ok. If 'make toolchains' completed successfully, you don't have to download manually. 50.6MB sounds about right, although the website listed it as 48.3MB.

So what is the error you're seeing now? arm-linux-gnueabihf-gcc: Command not found?

ghost commented 8 years ago

The error is which I've posted first (and you can see in the image above): 'cannot find -lteec'.

I've searched and I think it's because some libraries are missing. I've copied libteec.so to some certain paths but was not solved.

vchong commented 8 years ago

Sorry, I just saw the image.

Can you list the full path to the location of libteec.so?

ghost commented 8 years ago

Yes, of course, its 'devel/optee/optee_client/out/export/lib'

vchong commented 8 years ago

Ok, that looks right. What about contents of host/Makefile? I assume you're using the latest version of this repo? I just tried a build on my side and it's fine.

ghost commented 8 years ago

This is the contents of host/Makefile:

CC      = $(CROSS_COMPILE)gcc
LD      = $(CROSS_COMPILE)ld
AR      = $(CROSS_COMPILE)ar
NM      = $(CROSS_COMPILE)nm
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
READELF = $(CROSS_COMPILE)readelf

OBJS = hello_world.o

CFLAGS += -Wall -I../ta/include -I$(TEEC_EXPORT)/include
LDADD += -lteec -L$(TEEC_EXPORT)/lib

.PHONY: all
all: hello_world

hello_world: $(OBJS)
    $(CC) $(LDADD) -o $@ $<

.PHONY: clean
clean:
    rm -f $(OBJS) hello_world

I think it's not the latest version as I told you it is a virtual machine that a Linaro worker gave me, but I built another virtual machine and installed all from zero and it gave me the same error.

I think this is gonna drive me crazy :(

vchong commented 8 years ago

I think I see the problem. You defined TEEC_EXPORT wrong. It should be /home/optee/devel/optee/optee_client/out/export, but you defined it to /home/optee/devel/TEE/optee/dev/optee_client/out/export. Why?

vchong commented 8 years ago

The location of lcu14_optee_hello_world and optee_client should be the same, i.e. they should both be under the same root folder. In your case, /home/optee/devel/optee/

ghost commented 8 years ago

I think this could be the problem, but I don't know how to change this path. Here I show you what is my optee folder:

path1

And of course, they are under the same root folder as you can see.

vchong commented 8 years ago

Yes, the location is fine, so just try below again: cd to your lcu14_optee_hello_world-master directory export HOST_CROSS_COMPILE=$PWD/../toolchains/aarch32/bin/arm-linux-gnueabihf- export TA_CROSS_COMPILE=$PWD/../toolchains/aarch32/bin/arm-linux-gnueabihf- export TEEC_EXPORT=$PWD/../optee_client/out/export export TA_DEV_KIT_DIR=$PWD/../optee_os/out/arm/export-ta_arm32 make

ghost commented 8 years ago

Here you can see the execution:

issue

vchong commented 8 years ago

Ok, this log looks much better. Assuming you're using an older version of the repos. Under optee_os/out, you should see a directory that says arm-plat-<some_platform_name>? Change export TA_DEV_KIT_DIR=$PWD/../optee_os/out/arm/export-ta_arm32 to match what you see above, i.e. export TA_DEV_KIT_DIR=$PWD/../optee_os/out/arm-plat-<some_platform_name>/export-ta_arm32

Then run make again.

ghost commented 8 years ago

It works! It tells that nothing to do with 'all' but I think the built has been succesfull:

issue

So many thank you!