0

请帮我创建一个合适的 Makefile。

我正在尝试在 Linux 上使用 gcc-arm-none-eabi 编译 STM32L4 Discovery Azure 演示固件。我使用 STM32CubeMX 生成的 Makefile 并使用 kiel 项目文件 (.uvprojx) 中的文件和设置填充它。不幸的是,结果以链接错误终止。经过一些挖掘和脏补丁后,我能够让 Makefile 运行而没有错误。我的目标仍然是创建一个合适的 Makefile。如何在链接期间防止第 3 方代码发生冲突?

C_SOURCE = \
...
Src/azure_base64.c \
Middlewares/Third_Party/mbedTLS/library/base64.c

Src/azure_base64.c看起来只是一个包装

#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 

链接错误 -

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
4

0 回答 0