Git Product home page Git Product logo

Comments (14)

sseyod avatar sseyod commented on May 23, 2024 1

Looks like the solution was to do this in my app:

#define SENTRY_BUILD_STATIC 1
#include <sentry.h>

from sentry-native.

sseyod avatar sseyod commented on May 23, 2024 1

Hi @Swatinem,

OK, this has improved things, in that I then just see one missing symbol reported, which is __GSHandlerCheck_EH4.

1>mini_chromium.lib(rand_util.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck_EH4
1>crashpad_util.lib(split_string.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck_EH4
1>mini_chromium.lib(file_path.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck_EH4
1>mini_chromium.lib(logging.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck_EH4
... etc. etc. ...

I was able to fix that, by further modifying the build configuration for sentry native.

Note that my app is a Windows 10 Store app - that might explain why I needed to work around the __GSHandlerCheck_EH4 problem ... see the FH4 flags for compiler and linker.

My build notes are here, I hope they help you and others.

To build:
1)  Use Windows Explorer to delete any CMakeFile folder within this folder ...
  cd <my folder>\sentry-native\
2)  Patch CMakeLists.txt as follows:
===
  if(WIN32)
    set(SENTRY_DEFAULT_TRANSPORT "winhttp")
    # MY CHANGES BEGIN
    # https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake
    # https://devblogs.microsoft.com/cppblog/making-cpp-exception-handling-smaller-x64/
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT -d2FH4-")
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd -d2FH4-")
    set(CMAKE_CXX_STANDARD 17)
    add_link_options("-d2:-FH4-")
    # MY CHANGES END
elseif(APPLE OR LINUX)
    set(SENTRY_DEFAULT_TRANSPORT "curl")
else()
    set(SENTRY_DEFAULT_TRANSPORT "none")
endif()
===
3) Using Power Shell from the right folder:
  cmake . -DBUILD_SHARED_LIBS=OFF
4) This builds the debug version by default
  cmake --build . --parallel
5) build the Release version using Visual Studio 2019 directly
6) copy/move the .lib files as required
7) build and run my app

#define SENTRY_BUILD_STATIC 1
#include <sentry.h>

void MyAppInitialise () {
  sentry_options_t* options = sentry_options_new();
  sentry_options_set_dsn(options, "<put your id here>");
  sentry_init(options);

  sentry_capture_event(sentry_value_new_message_event(
    /*   level */ SENTRY_LEVEL_INFO,
    /*  logger */ "custom",
    /* message */ "It works!"
  ));
}

void MyAppTerminate() {
  // make sure everything flushes
  sentry_shutdown();
}

from sentry-native.

Prachiagrawal1 avatar Prachiagrawal1 commented on May 23, 2024 1

Followed it to use sentry for my cpp app till this step:
To build:

  1. Use Windows Explorer to delete any CMakeFile folder within this folder ...
  cd <my folder>\sentry-native\
  1. Patch CMakeLists.txt as follows:
  if(WIN32)
    set(SENTRY_DEFAULT_TRANSPORT "winhttp")
    # MY CHANGES BEGIN
    # https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake
    # https://devblogs.microsoft.com/cppblog/making-cpp-exception-handling-smaller-x64/
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT -d2FH4-")
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd -d2FH4-")
    set(CMAKE_CXX_STANDARD 17)
    add_link_options("-d2:-FH4-")
    # MY CHANGES END
elseif(APPLE OR LINUX)
    set(SENTRY_DEFAULT_TRANSPORT "curl")
else()
    set(SENTRY_DEFAULT_TRANSPORT "none")
endif()
  1. Using Power Shell from the right folder:
  cmake . -DBUILD_SHARED_LIBS=OFF
  1. This builds the debug version by default
  cmake --build . --parallel
  1. build the Release version using Visual Studio 2019 directly

and built the sentry .sln file in release mode after that made a project in cpp then tried including sentry to it but it says "No such directory" for sentry or issues with sentry.h library....how to resolve it.

from sentry-native.

sseyod avatar sseyod commented on May 23, 2024

My project requires multithreaded runtime library (/MT) - but the configuration of sentry is multithreaded DLL (even though I have configured as static library!)

Is there any way to fix that via Cmake? Otherwise, I can't link it...

Pete

from sentry-native.

sseyod avatar sseyod commented on May 23, 2024

Finally, having manually changed the flags in the Sentry projects to /MT, and rebuilding...
I now get loads of these errors when building my app:

1>sentry.lib(sentry_crashpad_backend.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in ABC.obj
...
1>crashpad_client.lib(crash_report_database.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck_EH4

Thanks, Pete

from sentry-native.

Swatinem avatar Swatinem commented on May 23, 2024

@sseyod can you try this again with the latest 0.2.1 release and close this if the issue is solved?
I do test on Windows 10 myself with VS2019 and it works fine. We now also have tests for VS2017 in place.

from sentry-native.

sseyod avatar sseyod commented on May 23, 2024

Hi @Swatinem,

Many thanks for getting back to me. I'll give it a go and report back!

Question for you: what is the best URL to look at, with regard to build instructions; some concrete examples of how to make the build in various configurations would be very helpful (see my above comments!) :)

For the record, I'm using VS2019 Community Edition, and C++17.

Best, Pete

from sentry-native.

Swatinem avatar Swatinem commented on May 23, 2024

Thanks for investigating @sseyod! This helps me a lot actually ;-)

I will try to find out how I can add these options directly to the library instead of globally, which would also need changes to our crashpad fork.

from sentry-native.

sseyod avatar sseyod commented on May 23, 2024

@Swatinem that is great news, many thanks for letting me know. Always good to help :) Pete

from sentry-native.

jan-auer avatar jan-auer commented on May 23, 2024

Note that in #190 we found out that Crashpad will likely not work for Windows 10 Store Apps since those can only consist of a single executable. To support that use case, we will need to add a Windows inproc backend, or the Breakpad backend.

from sentry-native.

sseyod avatar sseyod commented on May 23, 2024

@Swatinem if you're updating the Windows 10 build/configuration documentation, can you also please consider updating your CMakeLists.txt along the lines of my above suggested changes?

  if(WIN32)
    set(SENTRY_DEFAULT_TRANSPORT "winhttp")
    # MY CHANGES BEGIN
    # https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake
    # https://devblogs.microsoft.com/cppblog/making-cpp-exception-handling-smaller-x64/
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT -d2FH4-")
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd -d2FH4-")
    set(CMAKE_CXX_STANDARD 17)
    add_link_options("-d2:-FH4-")
    # MY CHANGES END

from sentry-native.

sseyod avatar sseyod commented on May 23, 2024

@Swatinem just wanted to thank you again for all your work on this - had my first usable crash report come through for Windows 10, and it was an easy fix!

from sentry-native.

sseyod avatar sseyod commented on May 23, 2024

Just a tip for others: once you've build the release version of you app, and you've built the package - here is how to upload all you need for the crash reports. Make sure you do this before trying to provoke a crash, or you won't get a usable crash report.

rem Set build number. *** Must *** match that in you Sentry initialisation code, e.g.:
rem sentry_options_set_release(options, "[email protected]");

sentry-cli-Windows-x86_64.exe releases new 1.2.3

rem  upload *all* the binaries - this will automatically find what is required.
rem run it from your "Release" folder that contains your .exe file...

sentry-cli-Windows-x86_64.exe upload-dif difutil check .

from sentry-native.

Swatinem avatar Swatinem commented on May 23, 2024

I think #283 should have fixed this, as it adds the /MT, etc switches. The use of FH4 seems to be something specific to your program that you should maintain in your own configuration.

from sentry-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.