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

can we compile MAX78000 projects with G++ instead of GCC? #826

Closed
khavernathy opened this issue Dec 12, 2023 · 2 comments · Fixed by #827
Closed

can we compile MAX78000 projects with G++ instead of GCC? #826

khavernathy opened this issue Dec 12, 2023 · 2 comments · Fixed by #827
Assignees
Labels
bug Something isn't working

Comments

@khavernathy
Copy link

khavernathy commented Dec 12, 2023

I'd like to use C++ code for a project. Changing main.c to main.cpp in one of the sample projects results in a bunch of undefined reference to ... errors.

make seems to compile the definition files fine

- CC /home/x/MaximSDK/Libraries/MiscDrivers/Camera/camera.c
- CC /home/x/MaximSDK/Libraries/MiscDrivers/Camera/ov7692.c
- CC /home/x/MaximSDK/Libraries/MiscDrivers/Camera/sccb.c
- CC /home/x/MaximSDK/Libraries/MiscDrivers/PMIC/max20303.c
...

but i get

/home/x/x/x/max78000/main.cpp:334: undefined reference to `camera_start_capture_image()'

even though I'm including camera.h at the top of main.cpp.

The call to camera_start_capture_image(); is simply that. No arguments passed, no return value.

If I change the name of the definition file camera.c (located in MaximSDK files /home/x/MaximSDK/Libraries/MiscDrivers/Camera) to camera.cpp, the error goes away. But then there is a cascade of new undefined reference errors from the files that camera.cpp depends on.

@Jake-Carter
Copy link
Contributor

Thanks for reporting this @khavernathy, I've just opened a PR to fix this. We were missing C++ guards in some of our display and camera files.

C++ is fully supported, and the camera drivers should compile with the PR changes.

@Jake-Carter Jake-Carter self-assigned this Dec 12, 2023
@Jake-Carter Jake-Carter added the bug Something isn't working label Dec 12, 2023
@khavernathy
Copy link
Author

khavernathy commented Dec 12, 2023

Thanks, for what it's worth, these are all the undefined references I get when changing main.c to main.cpp and attempting to build.

Also when I wrap the relevant header file with

#ifdef __cplusplus
extern "C" {
#endif
...

as you did in the PR commits, it seems to resolve the undefined reference error on my side.

/home/x/dev/x/max78000/main.cpp:164: undefined reference to `camera_start_capture_image()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:168: undefined reference to `camera_get_image(unsigned char**, unsigned long*, unsigned long*, unsigned long*)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:209: undefined reference to `release_camera_stream_buffer()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:176: undefined reference to `get_camera_stream_buffer()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:177: undefined reference to `camera_is_image_rcv()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:216: undefined reference to `get_camera_stream_statistic()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/build/main.o: in function `transmit_capture_uart()':
/home/x/dev/x/max78000/main.cpp:297: undefined reference to `clear_serial_buffer()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:304: undefined reference to `send_msg(char const*)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:310: undefined reference to `clear_serial_buffer()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:313: undefined reference to `MXC_UART_WriteBytes(mxc_uart_regs_t*, unsigned char const*, int)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/build/main.o: in function `main':
/home/x/dev/x/max78000/main.cpp:358: undefined reference to `cnn_enable(unsigned long, unsigned long)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:361: undefined reference to `cnn_boost_enable(mxc_gpio_regs_t*, unsigned long)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:364: undefined reference to `cnn_init()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:366: undefined reference to `cnn_load_weights()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:368: undefined reference to `cnn_load_bias()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:370: undefined reference to `cnn_configure()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:378: undefined reference to `camera_init(unsigned long)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:380: undefined reference to `camera_setup(int, int, pixformat_t, fifomode_t, dmamode_t, int)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:390: undefined reference to `camera_write_reg(unsigned char, unsigned char)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:422: undefined reference to `cnn_unload(unsigned long*)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:423: undefined reference to `cnn_stop()'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:426: undefined reference to `softmax_q17p14_q15(long const*, unsigned short, short*)'
/home/x/MaximSDK/Tools/GNUTools/10.3/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /home/x/dev/x/max78000/main.cpp:413: undefined reference to `cnn_start()'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants