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

Building a dynamic library using libmaix #10

Closed
pauceano opened this issue Mar 28, 2024 · 4 comments
Closed

Building a dynamic library using libmaix #10

pauceano opened this issue Mar 28, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@pauceano
Copy link

pauceano commented Mar 28, 2024

I am trying to build a dynamic library using libmaix but I cannot.
I want to build libZMQ library,

I copied the hello_world example in libmaix, I have put all sources in main/src and includes in main/include

I have added to /libmaix/examples/libzmq/main/CMakeLists.txt
list(APPEND ADD_DEFINITIONS -fPIC)
and register_component(SHARED)
I see in the logs that compile.cmake has activated to_dynamic_lib flag.
But, after compiling everything, it ends with the following error:
.....
[ 95%] Building CXX object main/CMakeFiles/main.dir/src/zmq_utils.cpp.o
[ 96%] Building CXX object main/CMakeFiles/main.dir/src/zmtp_engine.cpp.o
[ 97%] Linking CXX shared library libmain.so
[ 97%] Built target main
Scanning dependencies of target libzmq
[ 98%] Building C object CMakeFiles/libzmq.dir/exe_src.c.o
[ 99%] Linking C executable libzmq
/opt/toolchain-sunxi-musl/toolchain/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/6.4.1/../../../../arm-openwrt-linux-muslgnueabi/lib/crt1.o: In function _start_c': /home/caiyongheng/tina/out/astar-parrot/compile_dir/toolchain/musl-1.1.16/crt/crt1.c:17: undefined reference to main'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/libzmq.dir/build.make:89: libzmq] Error 1
make[1]: *** [CMakeFiles/Makefile2:301: CMakeFiles/libzmq.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
....

@Neutree
Copy link
Owner

Neutree commented Mar 28, 2024

seems not suport set main component as dynamic, you can create new component set to dynamic, and the so file will be in build dir.

This is a new feature request: Compile project to dynamic lib, I can support it later, but now you can resolve it by the upper method.

@Neutree Neutree added the enhancement New feature or request label Mar 28, 2024
@pauceano
Copy link
Author

Thank you for your rapid answer.
Sorry, I do not understand how "create new component set to dynamic"
Can you please detail?

@skb666
Copy link
Contributor

skb666 commented Mar 28, 2024

/libmaix/examples/libzmq/main 重命名这个文件夹(比如 libzmq)
再建一个 /libmaix/examples/libzmq/main
main 文件夹里搞一个 .c 再随便写个 main 函数
改 /libmaix/examples/libzmq/compile/priority 让 main 依赖 libzmq

@pauceano
Copy link
Author

Working, thanks.

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

No branches or pull requests

3 participants