Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to link package #81

Open
Ruannilton opened this issue Dec 22, 2020 · 1 comment
Open

Failing to link package #81

Ruannilton opened this issue Dec 22, 2020 · 1 comment

Comments

@Ruannilton
Copy link

I have a package that I am porting to the bake environment:
{ "id": "collections", "type": "package" }

and an application project thats depends on it:
{ "id": "collec_test", "type": "application", "value": { "use": [ "collections" ] } }

But when try to compile I get this error:

ruan@Mahlik:~/Dev/collec_test$ bake build
[ build] application collec_test => '.'
/usr/bin/ld: .bake_cache/x64-Linux-debug/obj/main.o: in function 'main':
/home/ruan/Dev/collec_test/./src/main.c:5: undefined reference to 'cvector_create_i'
collect2: error: ld returned 1 exit status
[ error] process 4040 exited with returncode 1
[ from] command returned 1
gcc -Wall -O0 .bake_cache/x64-Linux-debug/obj/main.o -L/home/ruan/bake/x64-Linux/debug/lib -L/home/ruan/bake/lib -lcollections -o ./bin/x64-Linux-debug/collec_test
[ from] command for task './bin/x64-Linux-debug/collec_test' failed
[ from] failed to build rule 'ARTEFACT'
[ error] build interrupted for collec_test in .
[ error] project 'collec_test' built with errors, skipping

When I go to the lib directory the .so file is presente there:

ruan@Mahlik:~/bake/x64-Linux/debug/lib$ ls
libcollections.so

And when I list the bake enviroment the package is there:

ruan@Mahlik:~$ bake list

Listing projects for platform:

  • x64-Linux

Packages & Applications:
P bake.amalgamate => all
C bake.lang.c => all
C bake.lang.cpp => all
C bake.opengl => all
C bake.sdl2 => all
C bake.sfml2 => all
P bake.test => all
P bake.util => all
P collections => [debug]

Summary:
applications: 0, packages: 9, templates: 0

The package code works well in other projects, so, I believe the cvector_create_i function is defined in the .so file.
Could someone explain to me what's wrong please?

@BlueRedBrackets
Copy link

BlueRedBrackets commented Jan 18, 2023

Disclaimer: I'm new to c, and I don't understand why/how this works.

To make cvector_create_i available in your collec_test application, you'll need to edit your main header file in the collections project (i.e. collections/include/collections.h). Try adding COLLECTIONS_API in front of the cvector_create_i definition.

COLLECTIONS_API void cvector_create_i();

Then, rebuild your app project with bake rebuild -r.

For me at least, running the app binary directly gives me an additional error message, but when I used bake run, I was able to run the app and call the package function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants