Hello ,
I am trying to build own custom platform and framwork, everything is ok, but I am stucking on python build script.
I have several *.lib libraries under the Windows platform. I need to link them last to ensure that all objects files can be linked successfully, but I have never been able to do this.
Here I tried two methods, the first is to use the (LIBS) environment variable, but it always links the .lib file with the (-l) prefix
- First method
#Build source code , this is the same part.
# THREADX
threadx_sources_dir = join(framework_dir, platform, core, env.sdk)
env.BuildSources(
join("$BUILD_DIR", platform), # 创建独立的子目录,
threadx_sources_dir,
src_filter="+<*.s>"
)
# bw
bw_sources_dir = join(framework_dir, platform, core, "bw")
env.BuildSources(
join("$BUILD_DIR","_bw"), # 创建独立的子目录
quectel_sources_dir,
src_filter="+<*.c>"
)
# PROJECT
project_sources_dir = join("$PROJECT_DIR", "lib")
env.BuildSources(
join("$BUILD_DIR","project"), #独立的子目录
project_sources_dir,
src_filter="+<*.c>"
)
#LINK code
lib_path = join(framework_dir, platform, core, env.sdk, "lib")
lib_files = glob.glob(os.path.join(lib_path, '*.lib'))
env.Append(LIBS = lib_files)
#Result
clang++ -o .pio\build\bg96\program.elf -d -target armv7m-none-musleabi -fuse-ld=qcld -lc++ -Wl,-mno-unaligned-access -fuse-baremetal-sysroot -fno-use-baremetal-crt -Wl,-entry=0x43000000 -Wl,-TC:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\c.ld -Wl,-Map=C:/Users/bakewell.wang/Documents/PlatformIO/Projects/321/.pio/build/bg96\program.map,-gc-sections -Wl,-gc-sections .pio\build\bg96\threadx\txm_module_preamble_llvm.o .pio\build\bg96\_quectel\quectel_uart_apis.o .pio\build\bg96\_quectel\quectel_utils.o .pio\build\bg96\src\main.o -L.pio\build\bg96 -lC:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\SDK30\lib\diag_dam_lib.lib -lC:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\SDK30\lib\qapi_psm_lib.lib -lC:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\SDK30\lib\timer_dam_lib.lib -lC:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\SDK30\lib\txm_lib.lib
**Fatal: cannot recognize namespec -lC:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\SDK30\lib\diag_dam_lib.lib**
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
*** [.pio\build\bg96\program.elf] Error 1
- Second method
#Code
lib_path = join(framework_dir, platform, core, env.sdk, "lib")
lib_files = glob.glob(os.path.join(lib_path, '*.lib'))
env.Append(LINKFLAGS = lib_files)
#Result ,Failed due to lib being linked first
clang++ -o .pio\build\bg96\program.elf -d -target armv7m-none-musleabi -fuse-ld=qcld -lc++ -Wl,-mno-unaligned-access -fuse-baremetal-sysroot -fno-use-baremetal-crt -Wl,-entry=0x43000000 -Wl,-TC:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\c.ld -Wl,-Map=C:/Users/bakewell.wang/Documents/PlatformIO/Projects/321/.pio/build/bg96\program.map,-gc-sections -Wl,-gc-sections C:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\SDK30\lib\diag_dam_lib.lib C:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\SDK30\lib\qapi_psm_lib.lib C:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\SDK30\lib\timer_dam_lib.lib C:\Users\bakewell.wang\.platformio\packages\framework-quectel\threadx\bg96\SDK30\lib\txm_lib.lib .pio\build\bg96\threadx\txm_module_preamble_llvm.o .pio\build\bg96\_quectel\quectel_uart_apis.o .pio\build\bg96\_quectel\quectel_utils.o .pio\build\bg96\src\main.o -L.pio\build\bg96
Error: .pio\build\bg96\threadx\txm_module_preamble_llvm.o(.relInit+0x18): undefined reference to `_txm_module_thread_shell_entry'
Error: .pio\build\bg96\threadx\txm_module_preamble_llvm.o(.relInit+0x2c): undefined reference to `_txm_module_callback_request_thread_entry'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x6c): undefined reference to `_txm_module_system_call5'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0xc4): undefined reference to `_txm_module_system_call11'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0xe0): undefined reference to `_txm_module_system_call5'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x130): undefined reference to `_txm_module_system_call11'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x1ec): undefined reference to `_txm_module_system_call11'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x274): undefined reference to `_txm_module_system_call11'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x2f4): undefined reference to `_txm_module_system_call5'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x348): undefined reference to `_txm_module_system_call11'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x390): undefined reference to `_txm_module_system_call5'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x3e0): undefined reference to `_txm_module_system_call11'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x468): undefined reference to `_txm_module_system_call5'
Error: .pio\build\bg96\_quectel\quectel_uart_apis.o(.text+0x484): undefined reference to `_txm_module_system_call5'
Error: .pio\build\bg96\_quectel\quectel_utils.o(.text+0x5c): undefined reference to `_txm_module_system_call11'
Error: .pio\build\bg96\src\main.o(.text+0xb8): undefined reference to `_txm_module_system_call12'
Error: .pio\build\bg96\src\main.o(.text+0xfc): undefined reference to `qapi_Timer_Sleep'
Error: .pio\build\bg96\src\main.o(.text+0x150): undefined reference to `_txm_module_system_call5'
Error: .pio\build\bg96\src\main.o(.text+0x164): undefined reference to `_txm_module_kernel_call_dispatcher'
Error: .pio\build\bg96\src\main.o(.text+0x1a0): undefined reference to `_txm_module_system_call4'
Error: .pio\build\bg96\src\main.o(.text+0x1c0): undefined reference to `_txm_module_system_call4'
Error: .pio\build\bg96\src\main.o(.text+0x280): undefined reference to `_txm_module_kernel_call_dispatcher'
Fatal: Linking had errors.
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
*** [.pio\build\bg96\program.elf] Error 1