AngusJohnson / Clipper2

Polygon Clipping and Offsetting - C++, C# and Delphi
Boost Software License 1.0
1.45k stars 266 forks source link

unresorved external symbol when use clipperoffset in visual studio #819

Closed axel9892 closed 5 months ago

axel9892 commented 5 months ago

hello, when i use clipper2 in visual studio i encounter link errors: first i generate dll and lib with solution Clipper2_DLL, and then use Clipper2_64.dll and Clipper2_64.lib in another project here is my code

` vector unclip(const vector& poly_pts, float unclip_ratio) { double poly_area = cv::contourArea(poly_pts); double poly_length = cv::arcLength(poly_pts, true); double offset = (unclip_ratio * poly_area) / poly_length;

        Clipper2Lib::ClipperOffset pco;
        Clipper2Lib::Path64 clipperpath;
        Clipper2Lib::Paths64 pathsaftoffset;

        for (size_t i = 0; i < poly_pts.size(); i++) {
            Clipper2Lib::Point64 clipper_point(poly_pts[i].x, poly_pts[i].y);
            clipperpath.push_back(clipper_point);
        }

        pco.AddPath(clipperpath, Clipper2Lib::JoinType::Round, Clipper2Lib::EndType::Polygon);
        pco.Execute(offset,pathsaftoffset);`

when i compile my project those errors occur:

Severity Code Description Project File Line Suppression State Details Error LNK2019 unresolved external symbol "public: void cdecl Clipper2Lib::ClipperOffset::AddPath(class std::vector<struct Clipper2Lib::Point<int64>,class std::allocator<struct Clipper2Lib::Point<__int64> > > const &,enum Clipper2Lib::JoinType,enum Clipper2Lib::EndType)" (?AddPath@ClipperOffset@Clipper2Lib@@QEAAXAEBV?$vector@U?$Point@_J@Clipper2Lib@@V?$allocator@U?$Point@J@Clipper2Lib@@@std@@@std@@W4JoinType@2@W4EndType@2@@Z) referenced in function "public: class std::vector<class cv::Point,class std::allocator<class cv::Point_ > > __cdecl dvsenseml::InferImplDBNet::unclip(class std::vector<class cv::Point,class std::allocator<class cv::Point_ > > const &,float)" (?unclip@InferImplDBNet@dvsenseml@@QEAA?AV?$vector@V?$Point@H@cv@@V?$allocator@V?$Point_@H@cv@@@std@@@std@@AEBV34@M@Z) infer_test D:\code\infer_test\infer_test\dbnet.obj 1

Severity Code Description Project File Line Suppression State Details Error LNK2019 unresolved external symbol "public: void cdecl Clipper2Lib::ClipperOffset::Execute(double,class std::vector<class std::vector<struct Clipper2Lib::Point<int64>,class std::allocator<struct Clipper2Lib::Point<__int64> > >,class std::allocator<class std::vector<struct Clipper2Lib::Point<__int64>,class std::allocator<struct Clipper2Lib::Point<__int64> > > > > &)" (?Execute@ClipperOffset@Clipper2Lib@@QEAAXNAEAV?$vector@V?$vector@U?$Point@_J@Clipper2Lib@@V?$allocator@U?$Point@_J@Clipper2Lib@@@std@@@std@@V?$allocator@V?$vector@U?$Point@_J@Clipper2Lib@@V?$allocator@U?$Point@J@Clipper2Lib@@@std@@@std@@@2@@std@@@Z) referenced in function "public: class std::vector<class cv::Point,class std::allocator<class cv::Point_ > > __cdecl dvsenseml::InferImplDBNet::unclip(class std::vector<class cv::Point,class std::allocator<class cv::Point_ > > const &,float)" (?unclip@InferImplDBNet@dvsenseml@@QEAA?AV?$vector@V?$Point@H@cv@@V?$allocator@V?$Point_@H@cv@@@std@@@std@@AEBV34@M@Z) infer_test D:\code\infer_test\infer_test\dbnet.obj 1

it shows compiler can't find symbol of addpath and execute what do i do wrong, and how can i fix it?

AngusJohnson commented 5 months ago

Why are you trying to use the DLL when you can compile the Clipper library inside your application? But if you must ... see https://stackoverflow.com/a/20410798/359538