HBadertscher / Matlab_BaslerCamDriver

A universal MATLAB driver for Basler cameras
MIT License
21 stars 5 forks source link

Mex won't find header files that are called via #include <header.h> even though they are in include path #15

Closed ebauch closed 7 years ago

ebauch commented 8 years ago

I have set up boost and pylon 4, and defined all the env variable but I have this strange thing that the compiler won't find header files that are specified within a header file via

#include <pylon/PylonInclude.h>,

even thought "pylon/PylonInclude.h" is in the include paths via the -I option. Changing

#include <pylon/PylonInclude.h>

into

include "fullpath/pylon/PylonInclude.h"

works, but of course, I don't want to change all the header files. There seems to be a similar question to this on Stack Overflow and this one on Mathworks, however, no solutions are presented. There must be something I am missing, such as setting C++ global variables or similar, so any help is appreciated!

Here is the minimal code I use to debug the issue:

libraries = {  'basler_helper', 'basler_set_get.cpp',      '-c';      ...
               'private',  'baslerGetRawCameraParams.cpp', '';       ...
            };
ipaths = [  '-I' fullfile(getenv('PYLON_ROOT'),'include') '-I' fullfile(getenv('PYLON_GENICAM_ROOT'),'library\CPP\include') '-I' fullfile(getenv('BOOST_ROOT'))]
lpaths = [  '-L' fullfile(getenv('PYLON_ROOT'),'lib\x64') '-L' fullfile(getenv('PYLON_GENICAM_ROOT'),'\library\CPP\Lib\win64_x64') '-L' fullfile(getenv('BOOST_ROOT'),'stage\lib')];
flags = {   '-largeArrayDims',...
            'CXXFLAGS=$CXXFLAGS -std=c++0x -fpermissive -fPIC -DNDEBUG', ...
            ... '-g', ...      % debug symbols
            ... '-v', ...      % verbose
        };

mex(flags{:},libraries{1,3},ipaths,lpaths,libraries{1,2})
HBadertscher commented 8 years ago

Hm, strange. I suspect that this has something to do with the PYLON_ROOT environment variable. You might have already checked that, but can you post the exact content of getenv('PYLON_ROOT') in MATLAB? In my case that is "C:\Program Files\Basler\pylon 4\pylon".

Another idea: in the minimal code you provided, you don't have any quotation marks around each path. This is needed if there are spaces in the path. Further, there are is no space between one path and the next '-I'. Does using the following ipath and lpath help? (Note the strange looking '"', which is a double quote inside single quotes, i.e. a string containing a ". Also there are spaces ' ' between the different paths.)

% Include paths
ipaths = [  '-I"',fullfile(getenv('PYLON_ROOT'),'include'),'"' ...
            ' ',...
            '-I"',fullfile(getenv('PYLON_GENICAM_ROOT'),'library\CPP\include'),'"', ...
            ' ',...
            '-I"',fullfile(getenv('BOOST_ROOT')),'"',...
         ];

% Library paths
lpaths = [  '-L"',fullfile(getenv('PYLON_ROOT'),'lib\x64'),'"', ...
            ' ','"',fullfile(getenv('PYLON_GENICAM_ROOT'),'\library\CPP\Lib\win64_x64'),'"', ...
            ' ','"',fullfile(getenv('BOOST_ROOT'),'stage\lib'),'"', ...
         ];