Please help me create a proper Makefile.
I'm trying to compile a STM32L4 Discovery Azure demo fw using gcc-arm-none-eabi on linux. I took a Makefile generated with STM32CubeMX and populated it with files and settings from the kiel project file (.uvprojx). Unfortunately the result terminates with an linking error. After some digging and a dirty patch, I was able to get the Makefile to run without error. Still my goal is to create a proper Makefile. How do I keep 3rd party codes from conflicting during linking?
C_SOURCE = \
...
Src/azure_base64.c \
Middlewares/Third_Party/mbedTLS/library/base64.c
Src/azure_base64.c looks to be just a wrapper
#Include "../Middlewares/Third_Party/Azure-IoT-SDK-C/c-utility/src/base64.c"
https://github.com/acornblue/AZURE_LAB
Projects/Multi/Applications/Azure_Sns_DM/Makefile
Projects/Multi/Applications/Azure_Sns_DM/MDK-ARM/B-L475E-IOT01/Project.uvprojx
Linking error -
build/base64.o: In function `Base64_Decoder': /home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/base64.c:188: multiple definition of `Base64_Decoder'
build/azure_base64.o:/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/Src/../../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/base64.c:188: first defined here
build/base64.o: In function `base64char': /home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/base64.c:19: multiple definition of `Base64_Encode_Bytes'
build/azure_base64.o:/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/Src/../../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/base64.c:19: first defined here
build/base64.o: In function `base64char': /home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/base64.c:19: multiple definition of `Base64_Encoder'
build/azure_base64.o:/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/Src/../../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/base64.c:19: first defined here
build/sha1.o: In function `SHA1Reset':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/sha1.c:84: multiple definition of `SHA1Reset'
build/azure_sha1.o:/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/Src/../../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/sha1.c:84: first defined here
build/sha1.o: In function `SHA1ProcessMessageBlock':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/sha1.c:366: multiple definition of `SHA1Input'
build/azure_sha1.o:/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/Src/../../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/sha1.c:366: first defined here
build/sha1.o: In function `SHA1ProcessMessageBlock':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/sha1.c:366: multiple definition of `SHA1FinalBits'
build/azure_sha1.o:/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/Src/../../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/sha1.c:366: first defined here
build/sha1.o: In function `SHA1ProcessMessageBlock':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/sha1.c:366: multiple definition of `SHA1Result'
build/azure_sha1.o:/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/Src/../../../../../Middlewares/Third_Parties/Azure-IoT-SDK-C/c-utility/src/sha1.c:366: first defined here
build/md_wrap.o: In function `sha1_process_wrap':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/mbedtls/library/md_wrap.c:364: undefined reference to `mbedtls_sha1_process'
build/md_wrap.o: In function `sha1_clone_wrap':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/mbedtls/library/md_wrap.c:352: undefined reference to `mbedtls_sha1_clone'
build/md_wrap.o: In function `sha1_ctx_free':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/mbedtls/library/md_wrap.c:358: undefined reference to `mbedtls_sha1_free'
build/md_wrap.o: In function `sha1_ctx_alloc':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/mbedtls/library/md_wrap.c:345: undefined reference to `mbedtls_sha1_init'
build/md_wrap.o: In function `sha1_finish_wrap':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/mbedtls/library/md_wrap.c:337: undefined reference to `mbedtls_sha1_finish'
build/md_wrap.o: In function `sha1_update_wrap':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/mbedtls/library/md_wrap.c:332: undefined reference to `mbedtls_sha1_update'
build/md_wrap.o: In function `sha1_starts_wrap':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/mbedtls/library/md_wrap.c:326: undefined reference to `mbedtls_sha1_starts'
build/md_wrap.o: (.rodata.mbedtls_sha1_info+0x1c): undefined reference to `mbedtls_sha1'
build/pem.o: In function `mbedtls_pem_read_buffer':/home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/mbedtls/library/pem.c:322: undefined reference to `mbedtls_base64_decode' /home/mxuser/projects/AZURE_LAB/Projects/Multi/Applications/Azure_Sns_DM/../../../../Middlewares/Third_Parties/mbedtls/library/pem.c:330: undefined reference to `mbedtls_base64_decode'
collect2: error: ld returned 1 exit status
Related
I have defined a following function:
def create_table(table,L):
table={'BBGTicker':L}
table=pd.DataFrame(table)
return table
trying to execute for example:
c=create_table(c,put_options_create)
where put_options_create is a list returns following error:
name 'c' is not defined.
If I was to write:
c={'BBGTicker':put_options_create}
c=pd.DataFrame(c)
this would work and give me a table.
What is wrong with the above function?
The first parameter of create_table is useless. table, the parameter, is immediately overwritten by table={'BBGTicker':L}, so there's no point in having that parameter.
Just change the function to:
def create_table(L):
table={'BBGTicker':L}
table=pd.DataFrame(table)
return table
and then call it as
c=create_table(put_options_create)
To answer why this is the case though: the variables between the () during a function call must already exist. If you haven't already assigned c a value, create_table(c,put_options_create) doesn't make sense. You only supply data there that you're giving a function. You don't specify in the parameter list data that you expect to get back*.
* It is possible to "return" data via parameters via mutation of objects, but that isn't what you're attempting to do here.
I would like to compile the cortex-r4's bootloader on linux with arm-linux-gnueabihf-gcc,the makefile gives me an undefined reference error:
autoinit.h:143: undefined reference to `__binit__'
autoinit.c:171: undefined reference to `WDTCTL_SYM'
exit.c:68: undefined reference to `__TI_pprof_out_hndl'
exit.c:68: undefined reference to `_symval'
I can't find where those are defined.
I am trying to compile code with arm-none-eabi-gcc, but I get the following errors. Can someone help me or explain to me what is the possible reason?
Thank you!
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function `exit':
/build/newlib-5zwpxE/newlib-2.2.0+git20150830.5a3d536/build/arm-none-eabi/newlib/libc/stdlib/../../../../../newlib/libc/stdlib/exit.c:70: undefined reference to `_exit'
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
/build/newlib-5zwpxE/newlib-2.2.0+git20150830.5a3d536/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/fstatr.c:62: undefined reference to `_fstat'
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/libc.a(lib_a-openr.o): In function `_open_r':
/build/newlib-5zwpxE/newlib-2.2.0+git20150830.5a3d536/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/openr.c:59: undefined reference to `_open'
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
/build/newlib-5zwpxE/newlib-2.2.0+git20150830.5a3d536/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/sbrkr.c:58: undefined reference to `_sbrk'
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':
/build/newlib-5zwpxE/newlib-2.2.0+git20150830.5a3d536/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/writer.c:58: undefined reference to `_write'
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
/build/newlib-5zwpxE/newlib-2.2.0+git20150830.5a3d536/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/closer.c:53: undefined reference to `_close'
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
/build/newlib-5zwpxE/newlib-2.2.0+git20150830.5a3d536/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/isattyr.c:58: undefined reference to `_isatty'
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
/build/newlib-5zwpxE/newlib-2.2.0+git20150830.5a3d536/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/lseekr.c:58: undefined reference to `_lseek'
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':
/build/newlib-5zwpxE/newlib-2.2.0+git20150830.5a3d536/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/readr.c:58: undefined reference to `_read'
Because you are compiling for a bare-metal target, newlib does not by default provide implementations for the functions that make only sense on a system with a console and an hard drive for example, basically system calls such as read/write/open/close/...
If you don' t need to those functions, using the --specs=nosys.specs option will make your application link with default, basically empty implementations that will return an error code when called:
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -o hello hello.c
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
/tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/stdlib/exit.c:64: undefined reference to `_exit'
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): in function `_sbrk_r':
/tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/reent/sbrkr.c:51: undefined reference to `_sbrk'
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): in function `_write_r':
/tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/reent/writer.c:49: undefined reference to `_write'
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): in function `_close_r':
/tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/reent/closer.c:47: undefined reference to `_close'
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): in function `_lseek_r':
/tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/reent/lseekr.c:49: undefined reference to `_lseek'
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): in function `_read_r':
/tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/reent/readr.c:49: undefined reference to `_read'
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): in function `_fstat_r':
/tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/reent/fstatr.c:55: undefined reference to `_fstat'
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): in function `_isatty_r':
/tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/reent/isattyr.c:52: undefined reference to `_isatty'
$
Using the --specs=nosys.specs option:
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc --specs=nosys.specs -o hello hello.c
$
An alternative, if you want to have your custom implementation of those missing system calls, is to create your own, minimal syscalls.c from the newlib libgloss/arm/syscalls.c source file: you can implement some system calls, and stubbing the others you don't need.
newlib source code can be browsed from here, and see section 12 System Calls and 12.1 Definitions for OS interface of the newlib documentation for more details.
I want to define a drop list menu in GTK with following codes:
GtkWidget *menu = gtk_menu_bar_new();
GtkWidget *menuitem = gtk_menu_item_new_with_label ("[Default Locale]");
gtk_menu_bar_append (GTK_MENU_BAR(menu), menuitem);
but I get following error:
undefined reference to `gtk_menu_bar_append'
collect2: ld returned 1 exit status
I do not want to use gtk_menu_shell_append. what should I do?
If you read the GtkMenuBar documentation there is no such function in Gtk3. GtkMenuBar is derived from GtkMenuShell so you should use gtk_menu_shell_append.
gcc -lGL -lGLU -lglut light.c
/tmp/ccfuthSi.o: In function `init':
light.c:(.text+0x72): undefined reference to `glClearColor'
light.c:(.text+0x7e): undefined reference to `glShadeModel'
light.c:(.text+0x99): undefined reference to `glMaterialfv'
light.c:(.text+0xb4): undefined reference to `glMaterialfv'
light.c:(.text+0xcf): undefined reference to `glLightfv'
light.c:(.text+0xdb): undefined reference to `glEnable'
light.c:(.text+0xe7): undefined reference to `glEnable'
light.c:(.text+0xf3): undefined reference to `glEnable'
/tmp/ccfuthSi.o: In function `display':
light.c:(.text+0x107): undefined reference to `glClear'
light.c:(.text+0x121): undefined reference to `glutSolidSphere'
light.c:(.text+0x126): undefined reference to `glFlush'
/tmp/ccfuthSi.o: In function `reshape':
light.c:(.text+0x150): undefined reference to `glViewport'
light.c:(.text+0x15c): undefined reference to `glMatrixMode'
light.c:(.text+0x161): undefined reference to `glLoadIdentity'
light.c:(.text+0x1bf): undefined reference to `glOrtho'
light.c:(.text+0x217): undefined reference to `glOrtho'
light.c:(.text+0x223): undefined reference to `glMatrixMode'
light.c:(.text+0x228): undefined reference to `glLoadIdentity'
/tmp/ccfuthSi.o: In function `main':
light.c:(.text+0x268): undefined reference to `glutInit'
light.c:(.text+0x274): undefined reference to `glutInitDisplayMode'
light.c:(.text+0x288): undefined reference to `glutInitWindowSize'
light.c:(.text+0x29c): undefined reference to `glutInitWindowPosition'
light.c:(.text+0x2a9): undefined reference to `glutCreateWindow'
light.c:(.text+0x2ba): undefined reference to `glutDisplayFunc'
light.c:(.text+0x2c6): undefined reference to `glutReshapeFunc'
light.c:(.text+0x2d2): undefined reference to `glutKeyboardFunc'
light.c:(.text+0x2d7): undefined reference to `glutMainLoop'
As you can see, i pass the required parameters to the gcc. Why it does not work? Linux Mint 12.
It really is a FAQ (and has been asked and answered many times here). Order of arguments matters when linking. Libraries should go last (and in the good order). You should run
gcc -Wall -g light.c -lGL -lGLU -lglut -o light