GuoZhao Kou
GuoZhao Kou

Reputation: 1

OpenNI2 Undefined symbols for architecture arm64, missing required architecture arm64

I'm trying to learn openni2. However, my first openni2 program went wrong. An error occurred while I was building the project. Undefined symbols for architecture arm64

I found many solutions on the Internet, but I didn't seem to find a suitable solution.

So I put forward this question. I hope someone can help me. Thank you!

I use Mac M1 and CLion.

Error:

ld: warning: ignoring file /opt/homebrew/Cellar/OpenNI2/Redist/libOpenNI2.dylib, missing required architecture arm64 in file /opt/homebrew/Cellar/OpenNI2/Redist/libOpenNI2.dylib (2 slices)
Undefined symbols for architecture arm64:
  "_oniGetExtendedError", referenced from:
      openni::OpenNI::getExtendedError() in main.cpp.o
  "_oniInitialize", referenced from:
      openni::OpenNI::initialize() in main.cpp.o
ld: symbol(s) not found for architecture arm64

My code:

#include <iostream>
#include <OpenNI.h>

using namespace std;
int main() {

    openni::Status status = openni::OpenNI::initialize();
    const char * log = openni::OpenNI::getExtendedError();
    return 0;
}

My CMakeList:

cmake_minimum_required(VERSION 3.20)
project(PCLTest)

set(CMAKE_CXX_STANDARD 14)
# OpenNI Path
set(OPENNI2_INCLUDE /opt/homebrew/Cellar/OpenNI2/Include)
set(OPENNI2_REDIST /opt/homebrew/Cellar/OpenNI2/Redist)
set(OPENNI2_LIBRARIES libOpenNI2.dylib)

find_package(PCL 1.12 REQUIRED COMPONENTS common io)

# PCL
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
# OpenNI2
include_directories(${OPENNI2_INCLUDE})
link_directories(${OPENNI2_REDIST})

add_definitions(${PCL_DEFINITIONS})

add_executable(PCLTest main.cpp)
target_link_libraries(PCLTest ${OPENNI2_LIBRARIES})
target_link_libraries(PCLTest ${PCL_LIBRARIES})


Upvotes: 0

Views: 140

Answers (0)

Related Questions