0

I'm new to Chrome Application development and the Native Client/PNaCL pipeline. I'm working on OS X Yosemite. I have installed naclports to use opencv. I have tried a C++ code that uses opencv and everything is ok.

Now, I would like to call my own C Library in this C++ code. First, I have to build it for nacl, and here's my problem (my library also uses opencv).

I have the following error when compiling:

    cc    -c -o mylib.o mylib.c
    In file included from mylib.c:3:
    In file included from /System/Library/Frameworks/opencv2.framework/Headers/opencv.hpp:52:
    In file included from /System/Library/Frameworks/opencv2.framework/Headers/video/video.hpp:47:
    /System/Library/Frameworks/opencv2.framework/Headers/video/background_segm.hpp:47:10: fatal error: 
  'list' file not found
    #include <list>
     ^
    1 error generated.
    make: *** [mylib.o] Error 1

Here is my Makefile:

    WARNING_FLAGS := -Wall -Wno-long-long -pedantic -Werror 
    CXXFLAGS := -lpthread $(WARNINGS) -I/opt/local/include/ -I/opt/local/include/opencv/ 
    LDFLAGS := -L/opt/local/lib/ -lopencv_objdetect -lopencv_imgproc -lopencv_core -lopencv_highgui -lopencv_contrib -lopencv_ml -lopencv_video -lz -lm -L/usr/X11R6/lib -lGLU -lGL -lXext -lX11

    GETOS := python $(NACL_SDK_ROOT)/tools/getos.py
    OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
    OSNAME := $(shell $(GETOS))

    PNACL_TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_pnacl)
    PNACL_CXX:=$(PNACL_TC_PATH)/bin/pnacl-clang++
    PNACL_CC:=$(PNACL_TC_PATH)/bin/pnacl-clang
    PNACL_AR:=$(PNACL_TC_PATH)/bin/pnacl-ar

    PNACL_CXXFLAGS := -I$(NACL_SDK_ROOT)/include $(CXXFLAGS) 
    PNACL_LDFLAGS := -L$(NACL_SDK_ROOT)/lib/pnacl/Release -lppapi_cpp -lppapi -lpthread $(LDFLAGS)

    SUFFIXES = .o .c .h .a .sl #.so 

    SRCS := mylib.c
    OBJS = $(SRCS:%.c=%.o)

    all:  mylib.a

    mylib.a:    $(OBJS) $(PNACL_CXX) -o $@ $< $(OBJS) -O2
    $(PNACL_CXXFLAGS) $(PNACL_LDFLAGS)
    @($(PNACL_AR) mylib.a $(OBJS))

    clean:
        $(RM) $(OBJS) mylib.a

I don't understand this opencv error.

poulette
  • 1
  • 1
  • looks like an include path problem in which the C++ STL include file for list is not being located by the compiler. – Richard Chambers Oct 28 '15 at 12:05
  • yes, but I don't understand why I don't have this error when compiling the C++ code. – poulette Oct 28 '15 at 12:35
  • From the error, it looks like the opencv2 is trying to pull in C++ STL components, specifically the `list` templates. See this question and answer [#include C++ header files in opencv](http://stackoverflow.com/questions/19177456/include-c-header-files-in-opencv) as well as [Can OpenCV be developed using C++ and C together](http://stackoverflow.com/questions/13686606/can-opencv-be-developed-using-c-and-c-together) – Richard Chambers Oct 28 '15 at 16:29
  • ok thank you very much – poulette Oct 30 '15 at 13:40

0 Answers0