Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8179297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:58:14+00:00 2026-06-06T23:58:14+00:00

I’m trying to use the C++ Boost library to write some depth data I

  • 0

I’m trying to use the C++ Boost library to write some depth data I get form my Kinect to the serial port. In order to do this I need to link the appropriate libraries with this pre-written Makefile. I wrote a basic program using boost/asio to get a feel for the libraries and in order to compile I had to link to the boost_system library located in /usr/local/lib and include the header files from /usr/local/include/boost. I figured to use it in my OpenNI code I’d just have to make the same connection from this Makefile instead.

    # take this file's dir
    COMMON_CPP_MAKE_FILE_DIR = $(dir $(lastword $(MAKEFILE_LIST)))

    include $(COMMON_CPP_MAKE_FILE_DIR)CommonDefs.mak

    # define a function to figure .o file for each source file (placed under intermediate directory)
    SRC_TO_OBJ = $(addprefix ./$(INT_DIR)/,$(addsuffix .o,$(notdir $(basename $1))))

    # create a list of all object files
    OBJ_FILES = $(call SRC_TO_OBJ,$(SRC_FILES_LIST))

    # define a function to translate any source file to its dependency file (note that the way we create
    # dep files, as a side affect of compilation, always puts the files in the INT_DIR with suffix .d)
    SRC_TO_DEP = $(addprefix ./$(INT_DIR)/,$(addsuffix .d,$(notdir $(basename $1))))

    # create a list of all dependency files
    DEP_FILES = $(call SRC_TO_DEP,$(SRC_FILES_LIST))

    # older version of gcc doesn't support the '=' symbol in include dirs, so we replace it ourselves with sysroot
    INC_DIRS_FROM_SYSROOT = $(patsubst =/%,$(TARGET_SYS_ROOT)/%,$(INC_DIRS))

    # append the -I switch to each include directory
    INC_DIRS_OPTION = $(foreach dir,$(INC_DIRS_FROM_SYSROOT),-I$(dir)) -I/usr/local/include/boost

    # append the -L switch to each library directory
    LIB_DIRS_OPTION = $(foreach dir,$(LIB_DIRS),-L$(dir)) -L$(OUT_DIR) -L/usr/local/lib 

    # append the -l switch to each library used
    USED_LIBS_OPTION = $(foreach lib,$(USED_LIBS),-l$(lib)) -lboost_system

    # append the -D switch to each define
    DEFINES_OPTION = $(foreach def,$(DEFINES),-D$(def))

    # tell compiler to use the target system root
    ifdef TARGET_SYS_ROOT
        CFLAGS += --sysroot=$(TARGET_SYS_ROOT)
        LDFLAGS += --sysroot=$(TARGET_SYS_ROOT)
    endif

    # set Debug / Release flags
    ifeq "$(CFG)" "Debug"
        CFLAGS += -O0 -g
    endif
    ifeq "$(CFG)" "Release"
        CFLAGS += -O2 -DNDEBUG
    endif

    CFLAGS += $(INC_DIRS_OPTION) $(DEFINES_OPTION)
    LDFLAGS += $(LIB_DIRS_OPTION) $(USED_LIBS_OPTION)

    # some lib / exe specifics
    ifneq "$(LIB_NAME)" ""
        OUTPUT_NAME = lib$(LIB_NAME).so
        CFLAGS += -fPIC -fvisibility=hidden
        ifneq ("$(OSTYPE)","Darwin")
            LDFLAGS += -Wl,--no-undefined
            OUTPUT_NAME = lib$(LIB_NAME).so
            OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) -shared
        else
            LDFLAGS += -undefined error
            OUTPUT_NAME = lib$(LIB_NAME).dylib
            OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) -dynamiclib -headerpad_max_install_names
        endif
    endif
    ifneq "$(EXE_NAME)" ""
        OUTPUT_NAME = $(EXE_NAME)
        OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS)
    endif
    ifneq "$(SLIB_NAME)" ""
        CFLAGS += -fPIC
        OUTPUT_NAME = lib$(SLIB_NAME).a
        OUTPUT_COMMAND = $(AR) -cq $(OUTPUT_FILE) $(OBJ_FILES)
    endif

    define CREATE_SRC_TARGETS
    # create a target for the object file (the CXX command creates both an .o file
    # and a .d file)
    ifneq ("$(OSTYPE)","Darwin")
    $(call SRC_TO_OBJ,$1) : $1 | $(INT_DIR)
        $(CXX) -MD -MP -MT "$(call SRC_TO_DEP,$1) $$@" -c $(CFLAGS) -o $$@ $$<
    else
    $(call SRC_TO_OBJ,$1) : $1 | $(INT_DIR)
        $(CXX) -c $(CFLAGS) -o $$@ $$<
    endif
    endef

    #############################################################################
    # Targets
    #############################################################################
    .PHONY: clean-objs clean-defs

    include $(COMMON_CPP_MAKE_FILE_DIR)CommonTargets.mak

    # create targets for each source file
    $(foreach src,$(SRC_FILES_LIST),$(eval $(call CREATE_SRC_TARGETS,$(src))))

    # include all dependency files (we don't need them the first time, so we can use -include)
    -include $(DEP_FILES)

    $(OUTPUT_FILE): $(OBJ_FILES)
        $(OUTPUT_COMMAND)

    clean-objs:
        rm -rf $(OBJ_FILES)

    clean-defs:
        rm -rf $(DEP_FILES)

    clean: clean-objs clean-defs

I added:

-I/usr/local/include/boost 

to the INC_DIRS_OPTION

-L/usr/local/lib

to the LIBS_DIRS_OPTION, and

-lboost_system

to the USED_LIBS_OPTION (asio relies on the boost system library for error generation of some sort)

I get this error:

c++ -o ../Bin/x64-Release/Sample-NiSimpleRead ./x64-Release/NiSimpleRead.o -arch i386 -arch x86_64 -L../../Lib -L../Bin/x64-Release  -lOpenNI -lboost_system 
ld: warning: ignoring file /usr/local/lib/libboost_system.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
  "boost::system::generic_category()", referenced from:
      __GLOBAL__I_a in NiSimpleRead.o
  "boost::system::system_category()", referenced from:
      __GLOBAL__I_a in NiSimpleRead.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [../Bin/x64-Release/Sample-NiSimpleRead] Error 1

I’ve tried adding the lib directory to my DYLD_LIBRARY_PATH which did nothing. I’ve also tried creating some kind of shared (*.so) library, first using the NiSimpleRead.o binary combined with the libboost_system.a file, which brought up a lot of errors. Then tried changing the boost_system.a file by itself, to a .so, which also did nothing. Any advice on this would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:58:16+00:00Added an answer on June 6, 2026 at 11:58 pm

    Your problem seems to be that you have only 64-bit Boost, and you’re trying to make an universal (both 32-bit and 64-bit) binary. Make sure to install dependencies in both 32-bit and 64-bit versions, or throw away this -arch i386 from your build instructions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.