On 07/04/2013 at 09:33, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;
---------
Hi to the developer community,
I am a long time Pascal/Delphi coder , but avoided C / C++ all the time as I could get my wanted results easily in Delphi, what I personally find is the best choice for me.
As a 3D artist and also long time C4D user, I would like to program now some ideas (like own created shader solutions etc) and decided therefore to go with C++ to have all the power available.
As we all know, Pascal/Delphi is almost not supported in the 3D-world and so I am standing here with very little knowledge about the C++-world.
I don't want to bother you with silly questions as I will try to get my needed knowledge via tutorials and books, but although I already did read the C++ R14 SDK and searched the web, I am not able to set up a simple 'Hello world'-Plugin with Visual Studio 2010 Express in C++.
Here is the problem with R14:
My Visual Studio 2010 setup for compiling the R14-'cinema4dsdk' Sample-Plugins in 64 bit is correct and compiles without faults (I added the missing linker path as decribed here in the forum in the linker/general .. additional libraries -> added c:\program files\microsoft sdks\windows\v7.1\lib\x64). The Plugins are then shown correctly in the C4D-Plugin-menue.
So far, so good.
But when I now try to use the compiled 'cinema4dsdk' Sample-Folder as a base for my own plugins (f.e. a simple 'Hello world' output), the problems begin.
I tried to go the way described here: http://www.andrewnoske.com/wiki/index.php?title=Cinema_4D\_-\_C%2B%2B_plugins to set up a new 64 bit plugin based on the 64-bit release-compiled 'cinema4dsdk'-example.
No luck.
Now I copied the whole 'cinema4dsdk'-Folder, renamed it in MyCPlugins, opened the cinema4dsdk.vcxproj in VS2010, renamed the project there to mycplugin and compiled with no other changes, what also worked.
Now I closed VS2010, went to the MyCPlugins-directory and renamed the cinema4dsdk.vcxproj in mycplugin.vcxproj. Then I stated VS2010 and opened mycplugin.vcxproj.
First surprise, the _api is gone now in the projekt-map explorer.
Now I deleted everything but the main.cpp both in the \source-folder as well as in the Project-map-tree.
I wrote this in main.cpp:
*****
#define ID_HELLOTEST 1000001
// unique ID for this plugin
#include "c4d.h"
//########################################
class HelloWorldTest : public CommandData // data class for creating new commands (previously known as "menu plugins")
{
public:
virtual Bool Execute(BaseDocument *doc)
{
MessageDialog("Hello World"); // simple popup message
GePrint("This is my first plugin"); // output to C4D's "Console window"
return TRUE;
}
};
//########################################
Bool PluginStart(void) // the main function C4D calls to begin your plugin (think of it as main)
{
return RegisterCommandPlugin( ID_HELLOTEST,"Hello World",
0,NULL,String("Hello World"),
gNew HelloWorldTest );
// registers a command plugin with C4D
// (ie: the class to execute when user selects "Hello World" under the Plugin menu)
}
void PluginEnd(void) // called when the plugin is unloaded from C4D
{
}
Bool PluginMessage(LONG id, void *data) // allows you to receive plugin messages from C4D or other plugins
{
return TRUE;
}
*****
The compilation failed (see below)
Then I used the simpliest code:
*****
// This is the main file of the CINEMA 4D SDK
//
// When you create your own projects much less code is needed (this file is rather long as it tries to show all kinds of different uses).
//
// An empty project simply looks like this:
//
#include "c4d.h"
//
Bool PluginStart(void)
{
// ...do or register something...
return TRUE;
}
//
void PluginEnd(void)
{
}
//
Bool PluginMessage(LONG id, void *data)
{
return FALSE;
}
//
*****
When I try to compile (no other changes are made), the linker always prompts an error:
1>LINK : fatal error LNK1104: Datei "D:\Programme\Grafik\MAXON\CINEMA 4D R14\resource\_api_lib\_api_Win32_Debug.lib" kann nicht geöffnet werden.
When I take a look at the Project-Settings -> Linker -> Befehlszeile, I have this in the compiled original cinema4dsdk.vcxproj:
**
/OUT:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\cinema4dsdk\cinema4dsdk.cdl64" /NOLOGO /LIBPATH:"c:\program files\microsoft sdks\windows\v7.1\lib\x64" /DLL "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "D:\Programme\Grafik\MAXON\CINEMA 4D R14 \resource\_api_lib\_api_x64_Release.lib" /NODEFAULTLIB:"LIBCD" /MANIFEST:NO /ManifestFile:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\cinema4dsdk\obj\cinema4dsdk\x64_Release\cinema4dsdk.cdl64.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\cinema4dsdk\obj\cinema4dsdk_x64_Release.pdb" /OPT:REF /PGD:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\cinema4dsdk\cinema4dsdk.pgd" /TLBID:1 /DYNAMICBASE /FIXED:NO /NXCOMPAT /IMPLIB:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\cinema4dsdk\obj\cinema4dsdk\x64_Release\cinema4dsdk.cdl64.lib" /MACHINE:X64 /ERRORREPORT:QUEUE
**
and after simply renaming the file in mycplugin.vcxproj, I have this when I reopen it in VS2010:
**
/OUT:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\MyCPlugins\mycplugin.cdl" /INCREMENTAL /NOLOGO /DLL "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "D:\Programme\Grafik\MAXON\CINEMA 4D R14 \resource\_api_lib\_api_Win32_Debug.lib" /NODEFAULTLIB:"LIBCD" /MANIFEST:NO /ManifestFile:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\MyCPlugins\obj\mycplugin\Win32_Debug\mycplugin.cdl.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\MyCPlugins\obj\mycplugin_Win32_Debug.pdb" /PGD:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\MyCPlugins\mycplugin.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:\Programme\Grafik\MAXON\CINEMA 4D R14\Plugins\MyCPlugins\obj\mycplugin\Win32_Debug\mycplugin.cdl.lib" /MACHINE:X86 /ERRORREPORT:QUEUE
**
I have set everything to 'Release' and 'X64' wherever I could find it, but always the same problem.
But when I rename the mycplugin.vcxproj back to cinema4dsdk.vcxproj and reopen it in VS2010, the _api is back again and the compilation works flawless.
I am frustrated.
The Delphi compiler can be anoying sometimes, but the C++ enviroment is hell.
I have no idea what do I wrong or how do I set up this correctly.
Does anyone have a working, valid for the current R14 SDK step-by-step description for setting up a 'blanko'-Plugin-Project as a start for getting my own code correctly compiled ?
Thanks for any solutions.