Boost logo

Boost Users :

From: Andrea Galeazzi (andrea.galeazzi_at_[hidden])
Date: 2007-12-18 11:31:47


2007/12/18, John Maddock <john_at_[hidden]>:
>
> Andrea Galeazzi wrote:
> >> Hi everybody,
> >> I'm trying to use boost in a .NET project written in C++ managed.
> >> When I build it in Debug version it's everything alright, but when I
> >> do it in Release version I've got this error:
> >> error LNK2001: unresolved external symbol "char __cdecl
> >> boost::re_detail::w32_toupper(char,unsigned long)" (?w32_toupper@
> >> re_detail_at_boost@@$$FYADDK_at_Z).
> >> In particular the error above is generated by the following row:
> >> regex_replace(std::string(p1, p2), transformer,
> >> replace_string,boost::format_all).
> >> So now I'm in a bind because I've completed my application but I
> >> cannot distribute it due to the fact that .NET allows to deliver
> >> only release version.
> >> Can some help me?
>
> Well we can try, but I've not seen that one before: "w32_toupper" is fully
> defined in w32_regex_traits.cpp so this shouldn't be a problem.
>
> How did you build the regex lib: as a native code library using bjam or as
> a
> managed code library? And just double checking the obvious, I hope you
> don't have either BOOST_ALL_NO_LIB or BOOST_REGEX_NO_LIB defined when
> building, or if you do that your project references the regex lib in some
> way?
>
> If you're in a rush, then one quick thing you could try is:
>
> * Add the #define BOOST_REGEX_NO_LIB to your project settings (so the
> auto-linking code is disabled).
> * Add the regex source code directly to your application (it's
> libs/regex/src/*.cpp)
>
> Then try rebuilding, if that works but bloats your application (does the
> .NET linker automatically remove unused code?), then try building regex as
> a
> managed code static library from within your IDE, and then add that
> project
> as a dependency to your app.
>
> I suspect that the original issue is caused by some weird build-settings
> interaction, but it might be hard to track down by anything except trial
> and
> error. Do let me know if you find the cause though, and I'll fix it if
> it's
> possible.
>
> Unless anyone else has seen this before...?
>
> HTH, John.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

Thanks John,
I followed your advise and now it works fine! The only bad thing is that I
must compile regex source in my own projects.

>>How did you build the regex lib: as a native code library using bjam or as
a
>>managed code library?
I use it as native code.
If you wanna go deeper into the problem you have just create a new CLR C++
Console Project with the following code:

int main(array<System::String ^> ^args)
{
    Console::WriteLine(L"Hello World");
    boost::regex
transformer("([+{}()\\[\\]$\\^|])|(\\*)|(\\?)|(\\.)|([\\\\/:])");
    const char* replace_string =
"(?1\\\\$1)(?2[^\\\\\\\\/\\:]*)(?3[^\\\\\\\\/\\:])(?4\\(\\?\\:\\\\.|$\\))(?5[\\\\\\\\\\\\/\\:])";
    const char* p1 = "xxxxxxxx";
    const char* p2 = "xxxxxxxx";
    regex_replace(std::string(p1, p2), transformer,
replace_string,boost::format_all);

    return 0;
}

(the code comes from your dos_wildcard class) and build it as release.
Let me know if you find out a better solution of this problem.
Cheers



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net