FW: Error from memcpy in cstring

Dingjun Chen Dingjun.Chen@geotechairborne.com
Thu Nov 9 13:14:00 GMT 2023


Hi, Hao, 

Yes, you are right. I did use a cross compiler generated by crosstool-NG 1.26.0 with GNU gcc 13.2 and MUSL libc. 

Please see below my full CMakeLists.txt and I look forward to your advice on how to fix it. 


/**********CMakeLists.txt*******************/
cmake_minimum_required(VERSION 3.25.3)

# the name of the target operating system
set(CMAKE_SYSTEM_NAME Linux)

# which C and C++ compiler to use
set(CMAKE_C_COMPILER "/home/Dingjun.Chen/x-tools/HOST-x86_64-pc-cygwin/i686-linux-musl/bin/i686-linux-musl-gcc.exe")
set(CMAKE_CXX_COMPILER "/home/Dingjun.Chen/x-tools/HOST-x86_64-pc-cygwin/i686-linux-musl/bin/i686-linux-musl-g++.exe")


# location of the target environment
set(CMAKE_FIND_ROOT_PATH  "${PROJECT_SOURCE_DIR}"
                          "${PROJECT_SOURCE_DIR}/bin")

# adjust the default behavior of the FIND_XXX() commands:
# search for headers and libraries in the target environment,
# search for programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

project(vtem_xyz VERSION 6.3.3 DESCRIPTION "DAQ VTEM")

message(STATUS "The CMake SOURCE directory is ${CMAKE_SOURCE_DIR}")
message(STATUS "The CMake BINARY directory is ${CMAKE_BINARY_DIR}${CMAKE_SOURCE_DIR}")
message(STATUS "The SOURCE directory of the '${PROJECT_NAME}' project is ${PROJECT_SOURCE_DIR}")
message(STATUS "The BINARY directory of the '${PROJECT_NAME}' project is ${PROJECT_BINARY_DIR}")
message(STATUS "The current SOURCE directory is ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "The current BINARY directory is ${CMAKE_CURRENT_BINARY_DIR}")

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
add_definitions( -DCYGWIN )

include_directories(
        "/home/Dingjun.Chen/x-tools/HOST-x86_64-pc-cygwin/i686-linux-musl/i686-linux-musl/include/c++/13.2.0"
        "/home/Dingjun.Chen/x-tools/HOST-x86_64-pc-cygwin/i686-linux-musl/lib/gcc/i686-linux-musl/13.2.0/include/ssp"
        "/home/Dingjun.Chen/x-tools/HOST-x86_64-pc-cygwin/i686-linux-musl/i686-linux-musl/sysroot/usr/include"
        "/home/Dingjun.Chen/x-tools/HOST-x86_64-pc-cygwin/i686-linux-musl/i686-linux-musl/sysroot/usr/include/asm"
        "/home/Dingjun.Chen/x-tools/HOST-x86_64-pc-cygwin/i686-linux-musl/lib/gcc/i686-linux-musl/13.2.0/include/ssp"
        "${PROJECT_SOURCE_DIR}/include"
        "/home/Dingjun.Chen/usr/include/rtd"
        "/home/Dingjun.Chen/usr/include/gsc"
     )
link_directories(
        "${PROJECT_SOURCE_DIR}/lib"
        )

file(GLOB all_SRCS
        "${PROJECT_SOURCE_DIR}/include/*.hh"
        "${PROJECT_SOURCE_DIR}/src/*.cc"
    )
add_executable(vtem_xyz ${all_SRCS} )
target_link_libraries(vtem_xyz libvga.so libvgagl.so libpthread.so librtd-dm6620.a)
 


-----Original Message-----
From: LIU Hao <lh_mouse@126.com> 
Sent: Thursday, November 9, 2023 8:07 AM
To: Dingjun Chen <Dingjun.Chen@geotechairborne.com>; Xi Ruoyao <xry111@xry111.site>; gcc-help@gcc.gnu.org
Subject: Re: FW: Error from memcpy in cstring

在 2023/11/9 21:00, Dingjun Chen 写道:
> PS C:\Users\Dingjun.Chen> g++ --version
> g++.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders) 
> g++13.2.0

This is the native compiler from x86_64-w64-mingw32 to itself (i.e. native Windows on x86-64)...


> include_directories(
>          "/home/Dingjun.Chen/x-tools/HOST-x86_64-pc-cygwin/i686-linux-musl/i686-linux-musl/include/c++/13.2.0"

... but you tell it to look for Linux headers? That's not a correct configuration. You will need a cross compiler, and maybe linker, etc.



-- 
Best regards,
LIU Hao



More information about the Gcc-help mailing list