Why Is Cmake Apparently Referring to Host System Files While Cross-Compiling a Net-Snmp Agent Despite a Proper Toolchain File Is Being Used

Why is CMake apparently referring to host system files while cross-compiling a Net-SNMP agent despite a proper toolchain file is being used?

FINAL SOLUTION:

Like explained on the question UPDATE, @Tsyvarev's answer fixed the linking part by providing the --sysroot switch to the compiler pointing to the root filesystem for ARM, but the problem of finding a stubs-32.h from the host system isn't fixed by that. Although it was part of the solution, it is important to note the primary observation had another cause: the include -I switches were being used directly as CFLAGS to the compiler, making it effectively look at the host system, since they where not prefixed with the root filesystem path for the ARM board (remember the flags were output directly by the net-snmp-config script, which was reporting flags for the native ARM build, so with "normal" paths instead). To fix that I used a CMake string command to remove all the -I switches from the NETSNMPCFLAGS variable:

# Gets compiling flags and libs linked to Net-SNMP
execute_process(COMMAND "${NETSNMPCONFIG}" "--base-cflags" OUTPUT_VARIABLE NETSNMPCFLAGS)
execute_process(COMMAND "${NETSNMPCONFIG}" "--agent-libs" OUTPUT_VARIABLE NETSNMPLIBS)
# removes the include dir switches "-I" from the NETSNMPCFLAGS, since we don't want
# the compiler to include paths relative to the host system in the compilation
string(REGEX REPLACE "-I[a-zA-Z0-9/]*" "" NETSNMPCFLAGS ${NETSNMPCFLAGS})

set(STRICT_FLAGS "-Wall -Wstrict-prototypes")
set(CFLAGS "-I. ${STRICT_FLAGS} ${NETSNMPCFLAGS}")

and put the root filesystem in an include_directories directive:

# Sets the flags to be used for compiling and linking the executable
set_source_files_properties(${SRCS} COMPILE_FLAGS ${CFLAGS})
include_directories(${CMAKE_FIND_ROOT_PATH}/usr/include)
add_executable(${CMAKE_PROJECT_NAME} ${SRCS})
target_link_libraries(${CMAKE_PROJECT_NAME} ${NETSNMPAGENT} ${NETSNMPMIBS} ${NETSNMP})

CMake cross-compiling: C flags from toolchain file ignored

I've found a temporary solution by replacing the line

SET(CMAKE_C_FLAGS "-std=gnu99")

by

SET(CMAKE_C_FLAGS "-std=gnu99" CACHE STRING "" FORCE)

How do I set up NET-SNMP with OpenVMS?

Why install net-snmp on OpenVMS? SNMP is included in the TCPIP stack.
Run @TCPIP$CONFIG (as SYSTEM) and enable SNMP in the server configuration.

Are you using OpenVMS Hobbyist license(s)? In that case you should be able to enable and start SNMP on OpenVMS. Lookup the TCPIP documentation on the HP site for directions on configuration.



Related Topics



Leave a reply



Submit