Change debug / compiler options

I’m shortly behind after making my first steps. I used to use ROOT for quite a while which is years ago and I was using it on Linux. Now, after forgetting a lot of things plus being in Windows, it seems there is a law which forces me to struggle again with each basic step…

However, I’m about to follow a tutorial and now I’m a bit stuck and can’t help myself as the debugging message is very short:

toy_ex.obj : error LNK2019: unresolved external symbol “public: __cdecl MySensitiveDetector::MySensitiveDetector(class G4String)” (??0MySensitiveDetector@@QEAA@VG4String@@@Z) referenced in function “private: virtual void __cdecl MyDetec
torConstruction::ConstructSDandField(void)” (?ConstructSDandField@MyDetectorConstruction@@EEAAXXZ) [C:\geant4\sim\toy_ex.vcxproj]
C:\geant4\sim\RelWithDebInfo\toy_ex.exe : fatal error LNK1120: 1 unresolved externals [C:\geant4\sim\toy_ex.vcxproj]

I remember that, back than, there was usually much more output which was usable for debugging. It was sometimes still a mystery but at least it pointed me to somewhere. This output here looks very different and, at least to me, not very helpful.
I’m building with "

cmake --build . --config RelWithDebInfo

". Is it possible to extend this debugging output somehow?

Thanks a lot in advance!
Best, Ben

Hi Benjamin

Sorry, I can’t help with this, but I’d just like to say that if you follow unofficial “tutorials” on the internet, you risk being on your own, outdated, etc. Please consult the official Installation Guide — Geant4 Installation Guide 11.0 documentation and Book For Application Developers — Book For Application Developers 11.0 documentation.

Best wishes
John

There are a variety of possible causes of this error: Linker Tools Error LNK2019 | Microsoft Docs

Some flags and utilities are available to help identify the source: Linker Tools Error LNK2019 | Microsoft Docs

It looks like the file/implementation of the MySensitiveDetector class is the issue though, so I would see if that actually has the MySensitiveDetector::MySensitiveDetector(class G4String) constructor declared and defined appropriately first.

1 Like

Thank you! I figured, I simply had to return any value inside this function (I didn’t show here). Sorry for bothering.

However, I’ve seen on Using gdb debugger in an efficient way - #3 by christian_castagna that I could use the G4 debugger via

cmake -DCMAKE_BUILD_TYPE=Debug .
make clean install

but I don’t know where to put this. As I’m compiling on Windows, I’m using this command in the terminal:

cmake --build . --config RelWithDebInfo

which produces an .exe in the folder RelWithDebInfo. I figured out I can compile via

cmake -DCMAKE_BUILD_TYPE=Debug .

but I can’t see an .exe file somewhere.

“Debug” is an alternative to “RelWithDebInfo”, so syoud be able to use your own original command line, suitably modified:

cmake --build . --config Debug
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.