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 7568327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:53:51+00:00 2026-05-30T14:53:51+00:00

I wrote a C++ DLL using VS 2010 which is used to wrap some

  • 0

I wrote a C++ DLL using VS 2010 which is used to wrap some program that does boolean operations on polygons.Its structure is as follows: There is a main header and .cpp whose methods are exposed by marks :

  __declspec(dllexport) 

Then inside one of those method I execute a call of one of the methods of my polygon program which is contained in a different c++ class which is a part of the library.I should note that in addition to calling that method I also create(in the main dll .cpp file) variables which are defined in that polygons program.Those variables are of types required to pass and receive numeric data from the polygon program.
Now ,what is wrong.When I run the an application that uses this dll I do two identical calls to the same method of the library -the one I explained above that calls a function of the polygon program.When I do those calls I pass some numeric data into the method and expect to get back a new data based on some calculations in the polygons program.First call returns the correct data but the second one returns kind of mix of the data from the first call and the second input data.I am not DLL expert but I took a look at this thread :

How do I use extern to share variables between source files?

And I wonder if that may be the source of the problem? As I mentioned I use some variables which are part of the polygon calculation class and I instantiate them in the main .cpp of the dll. Two of those variables take the input data from the user and get it into the method that calculates the result and the third variable is filled with the result returned by that function.
Any help will be greatly appreciated as I am really stuck with it at the moment.

EDIT: The variables I use from the polygon source class are defined in its header as follows:

 typedef std::vector< IntPoint > Polygon;
 typedef std::vector< Polygon > Polygons;

DLL Test program

#include "stdafx.h"
#include "Clipper_lib.h"

int _tmain(int argc, _TCHAR* argv[])
{
int subj[]={100,100,200,100,200,200,100,200};
int clip[]={100,100,200,100,200,200,100,200};
vector<vector<int>> solution;
vector<vector<int>> solution1;
Execute(subj,clip,solution);

Execute(subj,clip,solution1);


return 0;
}

DLL header :

 #include "clipper.hpp"  /// this is the working C++ class of polygons operations
 #include <vector>
 using namespace ClipperLib;
 using namespace std;
 extern Polygon subj;
 extern Polygon clip;
 extern Polygons solution;

 extern "C"
 {
__declspec(dllexport) void Execute(int subj[],int clip[],vector<vector<int>> &solution);

 }

DLL .cpp

// Clipper_lib.cpp : Defines the exported functions for the DLL application.
//
#include "Clipper_lib.h"

Clipper clipper;

void Execute(int subj[],int clip[],vector<vector<int>> &solution){

Polygon *subjP=new Polygon();
Polygon *clipP=new Polygon();
Polygons *solutionP=new Polygons();



 for(int i=0; i<8;i+=2){

     subjP->push_back(IntPoint(subj[i],subj[i+1]));

 }


 for(int b=0;b<8;b+=2){

     clipP->push_back(IntPoint(clip[b],clip[b+1]));
 }
 clipper.Clear();
 clipper.AddPolygon(*subjP,ptSubject);
 clipper.AddPolygon(*clipP,ptClip);
 clipper.Execute(ctIntersection,*solutionP);
for( vector<Polygon>::size_type d=0;d!=solutionP->size();++d){
    vector<int> poly;
    solution.push_back(poly);

    for(vector<IntPoint>::size_type k=0;k!=solutionP[d].size();++k){

        for(vector<IntPoint>::size_type s=0;s!=solutionP[d][k].size();++s){

            int numX=(int)solutionP[d][k][s].X;
            int numY=(int)solutionP[d][k][s].Y;
            solution[d].push_back(numX);
                solution[d].push_back(numY);
        }



    }



}
delete solutionP;
delete subjP;
delete clipP;

}

  • 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-05-30T14:53:52+00:00Added an answer on May 30, 2026 at 2:53 pm

    Well .Figured it out.Because the wrapper of this source was C based API I had to embrace all the C++ methods in the DLL with extern “C” .This way it works fine.Thanks for all the comments anyways .

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

Sidebar

Related Questions

Using Visual Studio 2005, I wrote a simple DLL in C that uses the
I recently wrote a DLL in C# (.Net 2.0) which contains a class that
I want to write SDK using Visual C++ 2010, which can be used by
I'm using a capture card dll which exports a function that provides an HGLOBAL
I have got a dll that I load in my program which reads and
I am using C to write a DLL that provides basic database connection functionality
I wrote a wrapper DLL for some native c++ functions and compiled it in
I've got a Windows DLL that I wrote, written in C/C++ (all exported functions
I wrote mfc c++ console application. This Application is using a dll and this
I'm using LINQ to SQL in ASP.NET MVC. I wrote some new code to

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.