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

  • Home
  • SEARCH
  • 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 9144073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:10:47+00:00 2026-06-17T10:10:47+00:00

I have the following situation: I’ve created dynamic library lib.so. This library uses another

  • 0

I have the following situation:

I’ve created dynamic library lib.so. This library uses another static library lib.a. Both of them use Boost library (I link them in CMake file). (I use this dynamic library in Java project)

This is code of file.cpp in lib.so, which calls getFilesFromDirectory() from lib.a

#include "DrawingDetector.h"
#include "../../DrawingDetection.h"
#include <vector>

#include <boost/filesystem/operations.hpp>

using namespace std;

JNIEXPORT void JNICALL Java_DrawingDetector_detectImage( JNIEnv * env, jobject, jstring jMsg)
{
    const char* msg = env->GetStringUTFChars(jMsg,0);
    vector<File> filesPic = getFilesFromDirectory(msg,0);
    env->ReleaseStringUTFChars(jMsg, msg);
}

This is code of getFilesFromDirectory() from lib.a:

#include <string.h>
#include <iostream>

#include <boost/filesystem/operations.hpp>

#include "DrawingDetection.h"

using namespace std;

using namespace boost;
using namespace boost::filesystem;

vector<File> getFilesFromDirectory(string dir, int status)
{
    vector<File> files;
    path directoty = path(dir);
    directory_iterator end;
    if (!exists(directoty))
    {
        cout<<"There is no such directory or file!"<<endl;
}
for (directory_iterator itr(directoty); itr != end; ++itr)
{
     if ( is_regular_file((*itr).path()))
     {
    //some code
     }
}
return files;
 }

But when my project invokes lib.so library, it raises the following message:

 java: symbol lookup error: /home/orlova/workspace/kmsearch/Images/branches/DrawingDetection/jni/bin/lib.so: undefined symbol:_ZN5boost11filesystem34path21wchar_t_codecvt_facetEv

As I found out it crushes in lib.a, when it tries to invoke boost method “path”.
But I declared all boost headers, and linked them in CMake file.
Can you explain, why it doesn’t recognize boost methods?

EDIT:

The version of my compiler gcc 4.6. And if I use 4.5 everything is fine!

Also if I use some boost methods directly in file.cpp in lib.so everything works fine, for example:

 JNIEXPORT void JNICALL Java_DrawingDetector_detectImage( JNIEnv * env, jobject, jstring jMsg)
 {
    const char* msg = env->GetStringUTFChars(jMsg,0);
    path directoty = path("/home/orlova");//if I use boost method here
    vector<File> filesPic = getFilesFromDirectory(msg,0);// then everything works fine 
    env->ReleaseStringUTFChars(jMsg, msg);
 }

BUT

JNIEXPORT void JNICALL Java_DrawingDetector_detectImage( JNIEnv * env, jobject, jstring jMsg)
{
   const char* msg = env->GetStringUTFChars(jMsg,0);
   //path directoty = path("/home/orlova");//if I don't use boost method here
   vector<File> filesPic = getFilesFromDirectory(msg,0);// then this method causes before-mentioned error!! 
   env->ReleaseStringUTFChars(jMsg, msg);

}

How can you explain this behavior of compiler?

Note, that error occurs in runtime.

SOLVED

The problem was in order of libraries in *target_link_libraries* in CMake file.

WRONG:

find_library( LIBRARY_MAIN 
        NAMES lib.a
        PATHS ../bin
          )

set ( LIB_JNI     
      jpeg
      ${OpenCV_LIBS}
      ${BOOST_LIB}
      ${LIBRARY_MAIN}//static library is the last in the list of libraries and after boost!
    )
target_link_libraries( ${PROJECT} ${LIB_JNI} )

RIGHT:

find_library( LIBRARY_MAIN 
        NAMES lib.a
        PATHS ../bin
          )

set ( LIB_JNI  
      ${LIBRARY_MAIN}
      jpeg
      ${OpenCV_LIBS}
      ${BOOST_LIB}//boost library is the last in the list and after static library!

    )
target_link_libraries( ${PROJECT} ${LIB_JNI} )
  • 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-17T10:10:49+00:00Added an answer on June 17, 2026 at 10:10 am

    It seems that you link Boost.Filesystem dynamically – if so, you have to ensure that this library gets loaded. You can do this either by adding it to LOCAL_LDLIBS line in Android.mk, or by pre-loading it manually before you load lib.so in Java code.

    Alternatively, just link Boost (and everything else) statically to lib.so and forget about all this dynamic mess. 🙂

    UPDATE1: with regards to the update you posted — try putting boost_filesystem.a as the last object in the linker line.

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

Sidebar

Related Questions

I have following situation: I use Struts2 as MVC cobtroller I use Spring as
I have the following situation in JavaScript: <a onclick=handleClick(this, {onSuccess : 'function() { alert(\'test\')
I have the following situation... I use CallableStatement from java.sql package. When I use
i have following situation: a powershell script with this variables: $RUBY = C:\installing\ruby\bin\ruby.exe $ARGS
I have the following situation: one activity (DateActivity) calls another activity (ListActivity) when a
I have following situation: $('selector').live('click', openSite); and open site takes the event like this
I have the following situation: I am using a third party .net library which
I have this following situation. volatile double val1 = 10.0; volatile double val2 =
I have following situation - Have a MongoService class, which reads host, port, database
I have following situation. In a constructor of a pseudo class I attach a

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.