Some Newbie questions
-
On 07/04/2013 at 12:38, xxxxxxxx wrote:
Hello Scott,
I will immediately check this out.
Thanks a lot. -
On 07/04/2013 at 13:57, xxxxxxxx wrote:
OK, found everything so far on Microbions tutorial, except this:
7.
rather than recompile the _api project from the cinema4dsdk example plugin (because you already did that when building the example, and it's a waste of time to do it again) you're going to link to the compiled API library, so you need to tell the linker where that is. In Linker\General, set Additional Library Directories to the folder which contains the library file _api_Win32_Debug.lib (this is normally the path Cinema 4D Rxx\resource\_api_lib)
I have a 64bit PC , and in my R14 _api_lib-Folder are only the files _api_x64_Debug.lib and _api_x64_Release.lib, but no _api_Win32_Debug.lib.
Where do I get it ? -
On 07/04/2013 at 14:07, xxxxxxxx wrote:
Uff, OK, got it.
Normally I would erase the previous post, but in case another Newbie is lost like I am currently, I write my problems and solutions here to make life much more easy for beginners.
The solultion for the missing _api_Win32_Debug.lib is, that before doing anything with preparing a structure for own plugins, one has to compile the 'cinema4dsdk.vcxproj' 4 times :- Debug win32
- Release Win32
- Debug X64
- Release X64
The targets have to be set in Build -> Configuration Manager for -api and cinema4dsdk.
if you get an error with 64 bit like:
LINK : I:\Program Files\MAXON\CINEMA 4D R14 Demo\plugins\cinema4dsdk\cinema4dsdk.cdl64 not found or not built by the last incremental link; performing full link
2>LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
, then do this:
in the linker/general .. additional libraries
add c:\program files\microsoft sdks\windows\v7.1\lib\x64I also changed the Plattformtoolset (Property-Manager of the project file (Rightclick project-file in Project-explorer, choose Properties),then tab 'Configuration -> Common') from v100 to Windows7.1SDK
After compiling 4 times, lately all necessary files are located in the R14 resource-folders.
Is that written anywhere ?
I am feeling like Indiana Jones, solving hidden secrets while a giant sphere is rolling down on me.........
-
On 07/04/2013 at 14:26, xxxxxxxx wrote:
Exactly. The way that the Cinema 4D project is set up, you can't build all of the Solution Configurations and Platforms in one go. See this StackOverflow question/answer for a way to make this possible for your own projects:
http://stackoverflow.com/questions/6444493/build-multiple-configurations-of-a-project-in-a-single-build-operation-in-visualDon't lose your hat and the pistol is easier than the sword (?)
-
On 07/04/2013 at 14:56, xxxxxxxx wrote:
I feel your pain.
It wasn't that long ago that I launched V.S. for the very first time. And I had a very hard time figuring out how to get everything set up too. Even with Steve's site as a guide.This is my own version of the information found on Steve's site.
It's written in a different way that makes more sense to my brain. Maybe it will help you out too:Instructions: -Create your plugin with the skeleton folder structure inside of it *** Make sure you have your main.cpp file set up. And in the source folder *** *** The main.cpp file is used to load the api .h files. As well as register your plugins*** -Put your plugin folder with the basic file structure in the C4D plugins folder -Create a new emtpy C++ project(uncheck make directory. And select the C4D plugins folder(not your new plugin folder) as the source) -Name your project the same name as your new plugin folder so it will write the solution into that folder properly -Add the Debug & Release property sheets to the project(view->otherwindows->propertymanager) by right clicking them and choose: CINEMA 4D R12\resource\_api_lib\ Then adding these files to the proper project folders: Debug | Win 32 = DebugWin32.props Debug | Win 32 = ReleaseWin32.props -For C4D R13 and later: Go into the cinema4dsdk folder which is found in the "plugins" folder. Then add the "projectsettings.props" file just like you added the DebugWin32.props & ReleaseWin32.props files. NOTE: MAXON suggests a different way to do this using macros instead. -Now right click the source folder and choose Add Existing Project Add your main.cpp file as well as any other .cpp or .h files files you might also have in your project VisualStudio will automatically load all of the .h files from the api into your solution In configuration properties General -Set Target Extension to .cdl -Set Configuration type to Dynamic Library.dll In configuration properties Debugging -Set Command to: C:\Program Files\MAXON\CINEMA 4D R12\CINEMA 4D.exe or whichever .exe version you'll launch with the debugger In configuration properties Linker -In General->Set Output File to the same name as your project and with the extension: .cdl -In General->Set Additional Library Directories to: C:\Program Files\MAXON\CINEMA 4D R12\resource\_api_lib -In Input-> Additional Dependencies. Add this to the list: _api_Win32_Debug.lib -in Advanced-> change Randomized Base Address to Disable Image Randomization (DYNAMICBASE:NO) DONE with 32 bit setup!! To set up 64 bit compiling we have more work to do: -From the top menu. Click the solution platforms dropdown and select Configuration Manager -On the right drop down list. Select "New" from the options.Then select x64 -Next be sure to also enable the BUild option for this new platform -Add the Debug & Release property sheets to the project just like you did with the 32 bit platform setup above -This time select these files from the _api_lib folder: Debug | Win 64 = DebugWin64.props Debug | Win 64 = ReleaseWin64.props Right click on the project in the solution window and select properties Set up the various options the same way you set up the 32 bit options with two exceptions: -In Linker->General: Set Output File to the same name as your project and with the extension: .cdl64 -In Linker Input->Additional Dependencies. Add this to the list: _api_x64_Debug.lib DONE with 32&64 bit setups!! #################### This is not needed...But if you want to add the api here's how to do it################################# ############################################################################################################################# -Right click the soultion and choose Add Existing Project: C:\Program Files\MAXON\CINEMA 4D R12\resource\_api_lib\_api.vcxproj -Right click the soultion and choose Project Dependancies then select your plugin from the drop down list -Make your plugin dependant on the api by enabling the checkmark -Add the existing source files to the source folder if you have them(main, etc.) #############################################################################################################################
-ScottA
-
On 07/04/2013 at 14:56, xxxxxxxx wrote:
@Robert: Yes, but the way of the sword is an art.
And like Musashi said:
"You must understand that there is more than one path to the top of the mountain"
― Miyamoto Musashi, A Book of Five Rings: The Classic Guide to Strategy
__
and
__
"from one thing, know ten thousand things"
― Miyamoto Musashi, The Book of Five Rings: Miyamoto Musashi
__
sou desu ne
@Scott: thank you -
On 07/04/2013 at 15:12, xxxxxxxx wrote:
hai, sou desu!
-
On 07/04/2013 at 15:22, xxxxxxxx wrote:
Maybe the moderators can pin this thread or ScottA's description on a top-level so Newbies like me can find a quick entry to a working Compiler-setup ?
-
On 07/04/2013 at 15:30, xxxxxxxx wrote:
That's very kind.
But as they say in jolly old England: "Not Bloody Likely".This is not the "official" way they want us to set things up in VS.
So I don't think it's something they would want to promote.The blog that I linked to does a pretty good job of explaining how to do the "official" set up. With images to help see it in action.
But I must confess. I've never actually tried it that way yet.-ScottA
-
On 07/04/2013 at 15:45, xxxxxxxx wrote:
Problem:
I thought I had set it all right as ScottA described, but when I try to build a simple Hello-World code, I get this error:
1>------ Neues Erstellen gestartet: Projekt: MyCPlugin, Konfiguration: Release x64 ------
1> main.cpp
1>d:\programme\grafik\maxon\cinema 4d r14\plugins\mycplugin\source\main.cpp(34) : fatal error C1083: Cannot open include file: 'c4d.h': No such file or directory
========== Alles neu erstellen: 0 erfolgreich, Fehler bei 1, 0 übersprungen ==========
Seems that I missed setting a path, but where ?
I tried to add 'D:\Programme\Grafik\MAXON\CINEMA 4D R14\resource\_api' to the additional libraries in the Linker-> Common Tab, but always the same error message -
On 07/04/2013 at 16:09, xxxxxxxx wrote:
There's two places under Linker to set up the dependencies.
Linker- >General->Additional Library Directories:
D:\Programme\Grafik\MAXON\CINEMA 4D R14\resource\_api_libLinker- >General->Additional Dependencies:
_api_x64_Debug.lib
NOTE: for the 32 bit build version this will be:_api_Win32_Debug.libAlso make sure you have a folder in your solution called External Dependencies.
And it has the c4d.h file in it amongst the various .h files.
If that's not there you did something wrong and need to start over again.I also strongly suggest focusing on just getting a 32 bit version to compile first.
Once you can compile 32 bit version. Then you can try to set up the 64 bit version.-ScottA
-Also
There are two folders named: _api & _api_lib
The one you want to use is: _api_lib -
On 07/04/2013 at 16:27, xxxxxxxx wrote:
Oh yeah. One other thing.
Make sure C4D is closed before you try to compile your plugin.
I can't tell you how many times I got caught on that one when I first started out. !Embarrassed
[URL-REMOVED]-ScottA
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 07/04/2013 at 16:30, xxxxxxxx wrote:
Hi Scott,
no, I don't have such a folder called External Dependencies in my new Plugin-solution.
Maybe I understood something wrong.
I have added now additionally the path:
D:\Programme\Grafik\MAXON\CINEMA 4D R14\resource\_api
to the **Linker- >General->Additional Library Directories **so there is now written in that line:
D:\Programme\Grafik\MAXON\CINEMA 4D R14\resource\_api_lib;D:\Programme\Grafik\MAXON\CINEMA 4D R14\resource\_api
f.e. for the Debug Win32, I have added in the Linker- >Input->Additional Dependencies:
_api_Win32_Debug.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
I made all steps before as described by you and Microbion and added also manually a folder 'Debug' with the files DebugWin32.props and DebugWin64.props copied from the cinema4dsdk-Folder and added manually the file projectsettings.props
What could be wrong then ? -
On 07/04/2013 at 17:10, xxxxxxxx wrote:
@Scott:
OK, I started again from scratch, this time exactly how you described.
I missunderstood some phrases in your text concerning the DebugWin32.props and DebugWin64.props procedure, but I had already done the right thing according to micobions tutorial.
Anyway, now a complete new try.
This time I have the External depencies folder listed in the project.
I only made the setup so far for Debug Win32, but when trying to build I get this time:
1>------ Neues Erstellen gestartet: Projekt: mycplugin, Konfiguration: Debug Win32 ------
1> main.cpp
1>LINK : fatal error LNK1104: Datei "_api_Win32_Debug.lib" kann nicht geöffnet werden.
========== Alles neu erstellen: 0 erfolgreich, Fehler bei 1, 0 übersprungen ==========
I'll finish all steps and see what the linker says then.
Edit: Oops, wrong path to the _api_lib, I copied it from your text.
Now, with the right path, the compiler runs through and I see:
1>------ Neues Erstellen gestartet: Projekt: mycplugin, Konfiguration: Debug Win32 ------
1> main.cpp
1> Bibliothek "D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\mycplugin\obj\mycplugin\Win32_Debug\mycplugin.cdl.lib" und Objekt "D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\mycplugin\obj\mycplugin\Win32_Debug\mycplugin.cdl.exp" werden erstellt.
1> mycplugin.vcxproj -> D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\mycplugin\mycplugin.cdl
========== Alles neu erstellen: 1 erfolgreich, Fehler bei 0, 0 übersprungen ==========
Hip Hip, Hurah
Now, I can finish the other settings.
Thanks, Scott, your tutorial finally made it. -
On 07/04/2013 at 17:19, xxxxxxxx wrote:
It's definitely tricky. And you have to get everything just right and in the proper sequence.
It took me several tries to get it working myself.Note:
The main.cpp file works in combo with the projectsettings.props, DebugWin32.props and ReleaseWin32.props files to automatically create that folder and then loads the proper api .h files into it. So it a critical thing to get right.Make it easier on yourself.
Only try to create a 32 bit Debug version at this point. Don't even bother with setting up the 32 bit Release options at this point. You can always add those other versions later on after you get it working.Make sure you have the proper source files before you even get started.
-Do you have a main.cpp file with code in it that registers your HelloWorld plugin?
If not. Your VS setup will not automatically add the External Dependencies folder with the needed api .h files in it. And you won't be able to build the project.If all else fails and you just can't get it working. And you get frustrated and just want to move on and make a very simple plugin.
You can always make plugins right inside the compiled SDK. It's much easier than trying to build a stand alone plugin framework. A lot of people start off making their first C++ plugin this way.I have a video tutorial about that here:https://sites.google.com/site/scottayersmedia/scripting
It's aimed at Coffee users trying to switch over to C++ and VS.
It's for R12. But I think most of it is still relevant.-ScottA
-
On 07/04/2013 at 17:28, xxxxxxxx wrote:
Very nice, I'll check it out tomorrow.
Thanks again for your kind help, otherwise I think I would never have had a chance to set this beast up in the right way.