Comments (14)
Looks like the solution was to do this in my app:
#define SENTRY_BUILD_STATIC 1
#include <sentry.h>
from sentry-native.
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.
Followed it to use sentry for my cpp app till this step:
To build:
- Use Windows Explorer to delete any CMakeFile folder within this folder ...
cd <my folder>\sentry-native\
- 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()
- Using Power Shell from the right folder:
cmake . -DBUILD_SHARED_LIBS=OFF
- This builds the debug version by default
cmake --build . --parallel
- 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.
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.
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.
@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.
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.
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.
@Swatinem that is great news, many thanks for letting me know. Always good to help :) Pete
from sentry-native.
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.
@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.
@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.
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.
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)
- Is there a way to get Sentry to use the debug symbols that are compiled in to the executable? HOT 11
- Crashpad linking error on x86_64 windows HOT 9
- Incorrect issue grouping on Windows HOT 5
- Feature Request: Provide explicit timings to the Performance Monitoring API HOT 4
- Add Linux distro meta-data to OS context. HOT 4
- Qt Android integration documentation HOT 7
- [native] Add support for Sentry Metrics
- Proposal: official crashpad handler as application exe HOT 1
- Set user agent string (sdk name + version) HOT 4
- Exception not catched in sentry - how to investigate why HOT 12
- [#inc-517] Re-test repros before and after applying Google Jan 24 updates HOT 2
- [#inc-517] Document caveats of signalhandlers and sigaltstack HOT 3
- [Epic] #inc-517 Followups
- [#inc-517] Add basic crashing test with asan (HW Asan, GWP-ASan)
- install issue HOT 4
- [linux] RISC-V 32/64 support HOT 1
- Android NDK Segfault crash related to `sentry_value_set_by_key_n` HOT 4
- Craspad under Epic's "Easy Anti-Cheat" HOT 4
- Stack overflow not sent to backend HOT 10
- Extend envelope API to allow event-specific attachments HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sentry-native.