1

I've got a C++ dll and I've used boost library to implement multithreading and then I’d like to use this dll in a C# program.
I did it and my program is running as I expected and there isn’t any problems in my system. When I create an installer with using of Advanced Installer and install it as a new program in my system, (which I've developed application on it) everything is ok too and there isn't any problems. But when I installed this program in other systems and run it, at first, program will run normally but when it wants to create threads and run them, program will be stopped.
A part of my codes in C++ dll are as follow:

struct ThreadParams
{
    int thetaStart,
        thetaEnd,
        rStart;
    vector<string> files;
}thParams;
const int NUM_OF_THREADS = 5;
extern "C"
{
    __declspec(dllexport) int __stdcall Start(const char *path)
    {
        thParams.files = listFilesInDirectory(path);
        int step = thParams.files.size()/NUM_OF_THREADS;
        thParams.rStart = 1;
        thParams.thetaStart = 0;
        thParams.thetaEnd = 360;

        boost::thread_group tgroup;
        FILE *output_text;
        char *buffer = new char[128];
        for (int i = 0; i < NUM_OF_THREADS; i++)
        {   
            sprintf(buffer,"out%d.txt",i+1);
            output_text = fopen(buffer,"wt");

            int start  = i*step;                
            int end  = (thParams.files.size() - (start+step)) >= step ? (start+step) : thParams.files.size();
            tgroup.create_thread(boost::bind(ThreadProcess,start,end,output_text,i+1));
        }
        tgroup.join_all();
        _fcloseall();
        delete buffer;
        buffer = NULL;
    }
}
void ThreadProcess(int start, int end, FILE *out, int threadID)
{
    for(int i = start; i < end; ++i)
    {
        fprintf(out,"%s\n",thParams.files[i].c_str());
    }
}

Could anybody help me to resolve this problem, please?
Thanks in advance.

Community
  • 1
  • 1
s.a.t
  • 39
  • 8
  • check dependencies http://stackoverflow.com/questions/10818717/how-to-find-out-what-dependencies-i-e-other-boost-libraries-a-particular-boost – volody Dec 15 '15 at 21:00

1 Answers1

1

Boost.thread is one of the few boost libraries which are not header-only and they need a compiled library to be present. Most likely, you linked your code with dynamic version of boost.thread.

Your solutions:

  1. Link with static version of boost.thread
  2. Include dynamic library with your distribution.
SergeyA
  • 61,605
  • 5
  • 78
  • 137
  • Thank @SergeyA for your answer.What I've done is add boost libraries and header files in Project "Property Pages" -> Configuration Properties -> Additional Directories and in "Additional Include Directories" and "Additional Library Directories" and also I've added these files in "C/C++ -> General -> Include Directories" and "Linker -> General -> Library Directories". May you explain to me what else should I do, please? – s.a.t Dec 16 '15 at 05:44