Error "sketchup.exe not found" when executing a C++ program created in VisualStudio

I’m trying to write my first C program to interact with Sketchup, I work with VisualStudio 2019, SketchupPro2018, this couldn’t be easily modified as I’m working for a big company and program have to be autorized by the informatic division.
I’ve no error when building the solution, but when I launch the program I have this message

And the output windows of VisualStudio I have this :
‘test_CLR_empty.exe’ (Win32): Loaded ‘C:\Users\frs921127\source\repos\test_CLR_empty\x64\Debug\test_CLR_empty.exe’. Symbols loaded.
*‘test_CLR_empty.exe’ (Win32): Loaded ‘C:\Windows\System32\ntdll.dll’. *
*‘test_CLR_empty.exe’ (Win32): Loaded ‘C:\Windows\System32\mscoree.dll’. *
*‘test_CLR_empty.exe’ (Win32): Loaded ‘C:\Windows\System32\kernel32.dll’. *
*‘test_CLR_empty.exe’ (Win32): Loaded ‘C:\Windows\System32\KernelBase.dll’. *
*‘test_CLR_empty.exe’ (Win32): Loaded ‘C:\Windows\System32\ucrtbased.dll’. *
*‘test_CLR_empty.exe’ (Win32): Loaded ‘C:\Windows\System32\vcruntime140d.dll’. *
The thread 0x4024 has exited with code -1073741515 (0xc0000135).
The thread 0x4d4 has exited with code -1073741515 (0xc0000135).
The program ‘[14440] test_CLR_empty.exe’ has exited with code -1073741515 (0xc0000135) ‘A dependent dll was not found’.

I’ve tried with and without launching SketchUp before, on another computer.

One thing I found strange is that in the output windows of VisualStudio it’s written (Win32), but I’ve selected the target X64 in the project properties.

Thanks for your help

For a standalone utility or a 3rd party application, you must include DLL libs from the SketchUp C SDK. The introductory page from the C SDK says:

The C API library for Windows is built using Microsoft Visual Studio 2019 (v142). It includes only 64-bit binaries. Building and releasing an application using the SketchUp C API for Windows requires including SketchUpAPI.dll and SketchUpCommonPreferences.dll, which can be found in the SketchUp C SDK for Windows. Also, the following C runtime DLLs must be included: msvcp140.dll and msvcr140.dll. Due to Microsoft binary compatibility, the runtime DLLs remain named “-v140.dll”

Alternatively the Microsoft Visual C++ 2019 Redistributable Packages can be used

FYI, for a C extension that runs inside SketchUp’s process, instead of the DLL files, the extension must be linked to the appropriate LIB files distributed with the SDK. (In this latter case, there are a few extra runtime functions that are defined only for the SketchUp application process.)

It is suggested to adapt the examples supplied with the SDK.

SketchUpAPI.dll, SketchUpCommonPreferences.dll and msvcp140.dll are listed in the “Resources Files” of the project, “MS de C++ 2019 Redistributable” is installed on my computer
I can’t found msvcr140.dll or -v140.dll on my computer
I’ve tried two method to launched the .exe generated when I rebuilt the solution
1- from the directory where it’s created : allways the same error “…couldn’t found SketchUp.exe”
2- from the SketchUp installation directory : no error when launching the exe, but it do nothing, and as it’s not launched from VisualStudio I’ve no debugging information.

The “-v140.dll” is a suffix refering to the 2 DLL files.

I also do not see "msvcr140.dll" in my "C:/Windows?System32/" folder on my machine.
I have such file for older versions 100 and 120, but perhaps it is no longer required for v140 of the runtime ?

EDIT: I have done a bit of searching and because of the introduction of the Universal C Runtime, the "msvcr140.dll" file is no longer required and does not exist.

@tt_su ?

(If so, then the SDK introductory page needs to be corrected.)

I’ve added the file sketchup.exe to the directory of my VisualStudio project, now the application start but immediatly send the message
“Exception thrown at 0x00007FF655C8725E (SketchUp.exe) in test_CLR_empty.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.”
At the ligne : “SUModelRef model = SU_INVALID;”
Of the SDK sample “WritingToAskpFile”

Are you linking against sketchup.lib instead of SketchUpAPI.lib?

SketchUpAPI.lib is what you should link against if you make your own application that uses the SketchUp C API.

sketchup.lib is what you should link against if you write an extension that runs inside of SketchUp.

If that is not the source of your issue, can you provide a bare minimum example project? It’s otherwise very hard to guess at your setup.


I’ve tried both and it don’t change anything.
I’ve spend to much time triyng programming for Sketchup so I give up the subject.