dyld:使用VTK运行C ++项目时找不到符号_PyBaseObject_Type

时间:2018-08-24 15:32:44

标签: c++ cmake vtk premake

我目前正在设置VTK以在我的项目中工作,我已经可以成功编译和链接,但是在运行应用程序时,我得到了:

~/Projects/myProj $ ./MyProjDebug
dyld: Symbol not found: _PyBaseObject_Type
  Referenced from: /usr/local/opt/vtk/lib/libvtkWrappingPython27Core-8.1.1.dylib
  Expected in: flat namespace
 in /usr/local/opt/vtk/lib/libvtkWrappingPython27Core-8.1.1.dylib
abort trap: 6

VTK是从brew安装的,我正在使用premake生成make文件(可以在这里找到:https://pastebin.com/0dpUUCDS)。下一部分来自我的premake5.lua,也是我目前在VTK库中进行链接的方式:

--------------------------------
-- Find external libs (vtk) --
--------------------------------
local vtkIncPath = os.getenv("VTK_INCLUDE")
local vtkDirPath = os.getenv("VTK_DIR")

if (vtkIncPath) then
   includedirs{vtkIncPath}
else
   error("Missing vtk headers.  Please ensure the headers installed in your include path.")
end
-- Do not use the system vtk directory
if (vtkDirPath) then    
   -- link all libraries manually
   function recursiveLibraries(path)
      linkoptions { "-L"..path}
      for file in lfs.dir(path) do
         if lfs.attributes(path..file, "mode") == "file" then
            local fileName = string.match(file, [[lib(.+).dylib]])
            if fileName == nil then fileName = string.match(file, [[lib(.+).a]]) end
            if fileName == nil then fileName = string.match(file, [[(.+).so]]) end
            if fileName == nil then
            else
               links{fileName}
            end
         elseif lfs.attributes(path..file, "mode") == "directory" then
            recursiveLibraries(path..file)
         end
      end
   end

   recursiveLibraries(vtkDirPath.."/lib/")
end

我想念任何图书馆吗?我在这里想念什么? cmake在做什么,我不是吗?

编辑:我已经更新了该功能,以便还链接所有.a.so文件。

Edit2:我不知道这是否重要,但是我还通过brew安装了python。

0 个答案:

没有答案