请帮我创建一个合适的Makefile。
我正在尝试使用linux上的gcc-arm-none-eabi编译STM32L4 Discovery Azure演示文件。我使用STM32CubeMX生成了一个Makefile,并使用kiel项目文件(.uvprojx)中的文件和设置填充它。不幸的是,结果以链接错误终止。经过一些挖掘和一个脏补丁,我能够让Makefile运行而不会出错。我的目标仍然是创建一个合适的Makefile。如何在链接期间保持第三方代码不冲突?
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