Borland C++ Builder LoadFromResourceID Results in EAccess Violation - c++

I'm using Borland C++Builder 5 to write a game program. I'm trying to load a bitmap from a resource file I created. I cannot get the bitmap to load from
the resource file either by ID or by Name. It will load from file, but I want
to use the resource file. Loading from ID or Name results in the following error message at runtime:
Project HoldemProbs.exe raised exception class EAcessViolation with message
'Access violation at address 0043F66E in module 'HoldemProbs.exe'.
Read of address 000003EB. Process stopped. Use Step or Run to continue.
I'm pretty new to C++ and C++Builder, and I am sure I am doing something wrong. I just can't figure out what. I think it probably has something to do with the HInstance value, but I don't know what.
Below are relevant pieces of code:
ResRC.h
#ifndef RESRC_H
#define RESRC_H
#define RC_REDBACK 1000
#endif
RedBack.rc
RC_REDBACK BITMAP "<MYSOURCEPATH>\RedBack.bmp"
HoldemProbs.cpp
#include <vcl.h>
#pragma hdrstop
USERES("HoldemProbs.res");
USEFORM("..\Source\HoldemCalc.cpp", Form1);
USERES("..\Source\RedBack.res");
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->Title = "HoldemEval";
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
HoldemCalc.cpp
#include <vcl.h>
#include <cstring.h>
#include <HoldemEval.hpp>
#include <Graphics.hpp>
#pragma hdrstop
#pragma resource "*.dfm"
#include <Graphics.hpp>
#include <ResRC.h>
#include "HoldemCalc.h"
#include <string>
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
CardBackTst(); //Run test of card back bitmap useage
}
CardBackTst.cpp
void CardBackTst(void){
Graphics::TBitmap* RedBack = new Graphics::TBitmap;
Form1 -> Debug -> Text = DEBUGTEXT; //See below for DEBUGTEXT
RedBack -> LoadFromResourceID ((ARG1),RC_REDBACK); //See below for ARG1
}
There is an Edit Box called Debug used to display debug information. At various times, DEBUGTEXT has been (w/o surrounding "s):
"(int)(GetModuleHandle(NULL)"
"reinterpret_cast<int>(HInstance)"
"(int)HInstance"
"(int)(GetModuleHandle("<MYFINALPATH>\\HoldemProbs.exe"))" // ANSI string
"RC_REDBACK" (This yielded the correct value -- 1000)
"reinterpret_cast<int>(RedBack -> Handle)"
"(int)(Form1 -> Handle)"
At various times, ARG1 has been each of the above values of DEBUGTEXT, except for RC_REDBACK. All have resulted in an EAccessViolation error.
The following statement to load from the resource name has been used
with each ARG1 value, with the same EAcessViolation result:
RedBack -> LoadFromResourceName ((ARG1),"MYPATH\\RedBack.bmp");
However, the following LoadFromFile() statement to load from the actual bitmap file does work:
RedBack -> LoadFromFile("MYPATH\\RedBack.bmp");

I see two problems with this code:
RedBack.rc does not have a #include "ResRC.h" statement:
#include "ResRC.h" // <-- add this!
RC_REDBACK BITMAP "<MYSOURCEPATH>\RedBack.bmp"
Without that, RC_REDBACK will not be #defined, and so the bitmap resource will be identified by the literal name "RC_REDBACK" and not by the ID number 1000. As such, you will have to use LoadFromResouceName() instead of LoadFromResourceID():
RedBack->LoadFromResourceName((unsigned)HInstance, "RC_REDBACK");
Use a resource viewer tool to verify how your resources are actually identified in the final executable.
inside of CardBackTst(), the global Form1 pointer may not have been assigned yet, since the TForm1 object is still being constructed. CardBackTst() should not be relying on the global pointer at all. It should take the Form pointer as an input parameter instead:
//#include "ResRC.h"
void CardBackTst(TForm1 *Form) {
Graphics::TBitmap* RedBack = new Graphics::TBitmap;
if (Form) Form->Debug->Text = DEBUGTEXT;
//RedBack->LoadFromResourceID((unsigned)HInstance, RC_REDBACK);
RedBack->LoadFromResourceName((unsigned)HInstance, "RC_REDBACK");
}
...
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
CardBackTst(this);
}
A better solution would be to pass in the TEdit directly instead of the TForm itself:
//#include "ResRC.h"
void CardBackTst(TEdit *Debug) {
Graphics::TBitmap* RedBack = new Graphics::TBitmap;
if (Debug) Debug->Text = DEBUGTEXT;
//RedBack->LoadFromResourceID((unsigned)HInstance, RC_REDBACK);
RedBack->LoadFromResourceName((unsigned)HInstance, "RC_REDBACK");
}
...
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
CardBackTst(Debug);
}
Or, use a callback function instead:
//#include "ResRC.h"
typedef void __fastcall (__closure *TCardDebugProc)(const String &);
void CardBackTst(TCardDebugProc DebugProc) {
Graphics::TBitmap* RedBack = new Graphics::TBitmap;
if (DebugProc) DebugProc(DEBUGTEXT);
//RedBack->LoadFromResourceID((unsigned)HInstance, RC_REDBACK);
RedBack->LoadFromResourceName((unsigned)HInstance, "RC_REDBACK");
}
...
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
CardBackTst(&LogDebug);
}
void __fastcall TForm1::LogDebug(const String &DebugText)
{
Debug->Text = DebugText;
}

Related

64-bit opendir and readdir in C++Builder

I'm using the VCL tools in C++Builder 11 for Windows desktop development. I am trying to get the C functions opendir and readdir to work in a 64-bit app. I have read the IBM website (link below) about the 64-bit version of opendir and readdir but I can't configure my code to work with the 64-bit versions. The code below shows a single button app with code that reads and displays the name of each file in a folder. This works as a 32-bit app. On the 64-bit platform this code fails in the while loop calling readdir. Can you show how to adjust this code so it works on the 64-bit VCL platform in C++Builder.
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include <dirent.h>
#include <System.SysUtils.hpp>
//-----------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//----------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
DIR *pDir;
struct dirent *dirU;
pDir = opendir( "C:\\test\\" );
if (pDir == NULL) {
ShowMessage("error");
}else{
int count = 1;
while ((dirU = readdir(pDir)) != NULL) //fails here
{
ShowMessage(dirU->d_name);
count++;
}
}
}
//------------------------
IBM 64 bit opendir and readdir
I'm at a loss why you are looking at the IBM site, feels like a flashback of a long long time ago. Anyway, why not use native functions like GetFiles? See https://docwiki.embarcadero.com/Libraries/Alexandria/en/System.IOUtils.TDirectory.GetFiles

Make a VB-dll and load it in C++ application

I have a problem I've been struggeling with for a full week now, and I'm not able to solve it by myself. I've been googeling, and searching in all kind of forums... I have found lots of "this might work", tried it, but no, no success. If anyone have any clue, please, please, help me!
I'v got, from an external source, lots of classes and functions written in VB that I need to be able to use from a C++ application. My first though was: no problem, I turn the VB code into a dll, and load it from my C++-program. This was though harder than I ever could imagine. My C++-program is not written in Visual Studio, but for simplicity I started with trying to load my VB dll (written in Visual Studio 2010) from a Visual Studio C++ application. This is my code so far:
VB-code : DllModule : Class-library project
DllModule.vb
Namespace DllModule
Public Module DllModule
Public Const DLL_PROCESS_DETACH = 0
Public Const DLL_PROCESS_ATTACH = 1
Public Const DLL_THREAD_ATTACH = 2
Public Const DLL_THREAD_DETACH = 3
Public Function DllMain(ByVal hInst As Long, ByVal fdwReason As Long,
ByVal lpvReserved As Long) As Boolean
Select Case fdwReason
Case DLL_PROCESS_DETACH
' No per-process cleanup needed
Case DLL_PROCESS_ATTACH
DllMain = True
Case DLL_THREAD_ATTACH
' No per-thread initialization needed
Case DLL_THREAD_DETACH
' No per-thread cleanup needed
End Select
Return True
End Function
'Simple function
Public Function Add(ByVal first As Integer, ByVal sec As Integer) As Integer
Dim abc As Integer
abc = first + sec
Return abc
End Function
End Module
End Namespace
DllModule.def
NAME DllModule
LIBRARY DllModule
DESCRIPTION "My dll"
EXPORTS DllMain #1
Add #2
C++-code : TryVbDllLoad : Console application
TryVbDllLoad.cpp
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <strsafe.h>
extern "C" {
__declspec(dllimport) int __stdcall Add(int, int);
}
typedef int (__stdcall *ptf_test_func_1_type)(int, int);
int __cdecl _tmain(int argc, _TCHAR* argv[])
{
HINSTANCE hdll = NULL;
hdll = LoadLibrary("DllModule.dll"); // load the dll
if(hdll) {
ptf_test_func_1_type p_func1=(ptf_test_func_1_type)GetProcAddress(hdll,"Add");
if(p_func1) {
int ret_val = (*p_func1)(1, 2);
} else {
DWORD dw = GetLastError();
}
FreeLibrary(hdll); // free the dll
} else {
DWORD dw = GetLastError();
}
return 0;
}
I can load the dll, but GetProcAddess returns NULL with error code 127 (the specified procedure could not be found).
I have tried to load the dll from a VB-application. This works (even without the .def-file). But I'm guessing there is no proper entry point created that the C++ application can use (when I open the dll in Dependency Walker I see no entry point or functions). I've tried compiling the VB-code both with and without "Register for COM interop".
1) What am I doing wrong?
2) If there isn't any nice way to solve this properly, what can I do instead of creating a dll? Is there any other way I can use the VB-classes and functions in my C++ application?
Kind Regards
Sara
Thanks for your answer Mare!
There must be some kind of error in my dll though, cause when I try to register is using regsvr32 I get: "The module C:/tmp/DllModule.dll was loaded, but the start address for DllRegisterServer was not found. Check that C:/tmp/DllModule.dll is a valid DLL- or OCX-file and try again."
Also, when I use
#import "C\tmp\DllModule.dll"
I get
fatal error C1083: Cannot open type library file: 'c:\tmp\dllmodule.dll'
I looked at the link with the tutorial, but there is a small problem: there are no such thing as "ActiveX DLL" to choose among all the project types. And yes, I do have Visual Studio 2010 Professional (a trial version, but still).
-- Sara
Thanks for all the input. I've come across another way to solve my problem, using a multifile assembly rather than my first dll approach.
I followed this HowTo-section: http://msdn.microsoft.com/en-us/library/226t7yxe.aspx#Y749
VB-code : DllModule : Class-library project
DllModule.vb
Imports System.Runtime.InteropServices
Namespace DllModuleNS
Public Class Class1
Public Function ClassAdd(ByRef first As Integer, ByRef sec As Integer) As Integer
Dim abc As Integer
abc = first + sec
Return abc
End Function
End Class
End Namespace
This file I compiled using both visual studio (to produce DllModule.dll-file) and cmd-line:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Vbc.exe /t:module DllModule.vb
(to produce DllModule.netmodule-file).
C++-code : TryVbDllLoad : Console application
TryVbDllLoad.cpp
#using <mscorlib.dll>
#using ".\..\ClassLibrary1\DllModule.netmodule"
using namespace DllModule::DllModuleNS;
int _tmain(int argc, _TCHAR* argv[])
{
Class1^ me = gcnew Class1();
int a = 1, b = 2;
int xx = me->ClassAdd(a, b);
return 0;
}
In the TryVBDllLoad-project properties I changed:
Common Properties -> Framework and References : added DllModule-project as reference
Configuration Properties -> C/C++ -> General : /clr flag set
Configuration Properties -> Linker -> Input : Add Module To Assembly set to path to DllModule.netmodule (/ASSEMBLYMODULE:"DllModule.netmodule")
This resulted in that I could use the VB-class Class1 in VC++ code!
PROBLEM SOLVED!
I now took it one step further, and changed the TryVBDllLoad-project to a dll:
Configuration Properties -> General : Configurationtype Dynamic Library (.dll)
Configuration Properties -> Linker -> System : SubSystem Windows (/SUBSYSTEM:WINDOWS)
TryVbDllLoadClass.h
#ifndef TryVbDllLoadClass_H
#define TryVbDllLoadClass_H
class TryVbDllLoadClass
{
public:
TryVbDllLoadClass();
int Add(int a, int b);
};
#endif // TryVbDllLoadClass_H
TryVbDllLoadClass.cpp
#include "TryVbDllLoadClass.h"
#using <mscorlib.dll>
#using ".\..\ClassLibrary1\DllModule.netmodule"
using namespace DllModule::DllModuleNS;
TryVbDllLoadClass::TryVbDllLoadClass() {}
int TryVbDllLoadClass::Add(int a, int b)
{
Class1^ me = gcnew Class1();
int xx = me->ClassAdd(a, b);
return xx;
}
DllExport.h
#ifndef DLLEXPORT_H
#define DLLEXPORT_H
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#ifdef __dll__
#define IMPEXP __declspec(dllexport)
#else
#define IMPEXP __declspec(dllimport)
#endif // __dll__
extern "C" {
IMPEXP int __stdcall AddFunction(int);
}
#endif // DLLEXPORT_H
DllMain.h
#define __dll__
#include "dllExport.h"
#include " TryVbDllLoadClass.h"
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return 1;
}
TryVbDllLoadClass * my;
IMPEXP int __stdcall AddFunction(int first, int second)
{
my = new TryVbDllLoadClass();
int res = my->Add(first, second);
delete my;
return res;
}
This dll I could then add to a non-visual-studio project just like a normal dll:
C++-code : LoadDll : Non-Visual-Studio-project (CodeBlocks in this case)
main.cpp
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "dllExport.h"
typedef int( * LPFNDLL_CREATE)(int, int);
HINSTANCE hDLL;
LPFNDLL_CREATE func;
using namespace std;
int main()
{
cout << "Hello world!" << endl;
int key = 35;
hDLL = LoadLibrary("TryVbDllLoadClass.dll");
if(hDLL)
{
cout << "Loaded: " << hDLL << endl;
func = (LPFNDLL_CREATE) (GetProcAddress(hDLL, "_AddFunction#4"));
if(func != NULL)
{
cout << "Connected: " << func << endl;
cout << "Function returns: " << func(key, key) << endl;
}
else cout << " ::: fail: " << GetLastError() << endl;
FreeLibrary(hDLL);
cout << "Freed" << endl;
}
else cout << " ::: fail: " << GetLastError() << endl;
printf("-> Goodbye world!\n");
return 0;
}
This way I can use the VB-classes given to me in my existing C++-project created outside Visuabl Studio. Finally...:)
With VB you do not get a "normal" DLL (at least this was the case in former times).
And you do not get Entry Points for functions.
But as i understood you, you have the VB source code and you can do with it whatever
is necessary. Here is a possible solution:
http://www.codeproject.com/Articles/21/Beginner-s-Tutorial-Calling-Visual-Basic-ActiveX-D
but try out first this less complicated way,
because i think a VB dll is always a COM dll, so you can:
register the dll using the Windows command
regsvr32 F:\proj\VBDllModule.dll
now your C++ code :
#import "F:\proj\VBDllModule.dll"
using namespace DllModule;
void CDialogTestDlg::OnButton1()
{
HRESULT hresult;
CLSID clsid;
_CTest *t; // a pointer to the CTest object
_bstr_t bstrA = L"hello";
_bstr_t bstrB = L" world";
_bstr_t bstrR;
::CoInitialize(NULL);
hresult=CLSIDFromProgID(OLESTR("VBTestLib.CTest"), &clsid);
hresult= CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,
__uuidof(_CTest),(LPVOID*) &t);
if(hresult == S_OK)
{
bstrR = t->vbConcat(bstrA , bstrB);
AfxMessageBox((char*)bstrR);
}
}

C++ Builder console application that calls a webservice (hello world)

I am trying write a "Hello World" example using C++Builder. This is my first project so I have probably made a simple mistake.
I want to create a console application that calls a calculator web service.
I open C++Builder 2007 and I create a Console Application. A cpp file called File1.cpp appears. Here it is the content:
//---------------------------------------------------------------------------
#include <iostream.h>
#include <vcl.h>
#pragma hdrstop
#include "calculator.h"
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
double a, b;
cout << "Enter the values to sum\n";
cout << "A: ";
cin >> a;
cout << "B: ";
cin >> b;
cout << "\nA+B:";
cout << GetCalculatorSoap()->Add(1,2);
cout << "\n\nPress any key to continue...";
getchar();
return 0;
}
//---------------------------------------------------------------------------
Additionally I added the soap proxy going into New->Other->WebService->WSDL Importer.
Using the WSDL http://www.dneonline.com/calculator.asmx?WSDL
This action added calculator.cpp:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://www.dneonline.com/calculator.asmx?WSDL
// >Import : http://www.dneonline.com/calculator.asmx?WSDL:0
// Encoding : utf-8
// Version : 1.0
// (21/02/2012 19:48:31 - - $Rev: 10138 $)
// ************************************************************************ //
#include <vcl.h>
#pragma hdrstop
#if !defined(calculatorH)
#include "calculator.h"
#endif
namespace NS_calculator {
_di_CalculatorSoap GetCalculatorSoap(bool useWSDL,
AnsiString addr, THTTPRIO* HTTPRIO)
{
static const char* defWSDL= "http://www.dneonline.com/calculator.asmx?WSDL";
static const char* defURL = "http://www.dneonline.com/calculator.asmx";
static const char* defSvc = "Calculator";
static const char* defPrt = "CalculatorSoap";
if (addr=="")
addr = useWSDL ? defWSDL : defURL;
THTTPRIO* rio = HTTPRIO ? HTTPRIO : new THTTPRIO(0);
if (useWSDL) {
rio->WSDLLocation = addr;
rio->Service = defSvc;
rio->Port = defPrt;
} else {
rio->URL = addr;
}
_di_CalculatorSoap service;
rio->QueryInterface(service);
if (!service && !HTTPRIO)
delete rio;
return service;
}
// ************************************************************************ //
// This routine registers the interfaces and types exposed by the WebService.
// ************************************************************************ //
static void RegTypes()
{
/* CalculatorSoap */
InvRegistry()->RegisterInterface(__interfaceTypeinfo(CalculatorSoap),
L"http://tempuri.org/", L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__interfaceTypeinfo(CalculatorSoap),
L"http://tempuri.org/%operationName%");
InvRegistry()->RegisterInvokeOptions(__interfaceTypeinfo(CalculatorSoap),
ioDocument);
}
#pragma startup RegTypes 32
}; // NS_calculator
When I run the application it raises an exception when calling GetCalculatorSoap()->Add(1,2):
---------------------------
Debugger Exception Notification
---------------------------
Project Test.exe raised exception class EOleSysError
with message 'CoInitialize has not been called'.
---------------------------
Break Continue Help
---------------------------
Debugging it seems the GetCalculatorSoap() executes ok, but just before calling the Add method the exception is thrown...
Any ideas what is wrong? Thanks!
The error message tells you what the problem is - CoInitialize has not been called. (Actually, it's preferable to call CoInitializeEx instead, but either will work.)
Your SOAP code is using COM methods, and therefore COM has to be initialized first. This is done on a per-thread basis.
You can fix it by calling CoInitialize(NULL);' at the beginning of your main function. Don't forget to call CoUnitialize(); at the end of main as well.
In Delphi, CoInitialize/CoUninitialize are declared in the ActiveX unit. In C++Builder, it seems to be in OBJBASE.H (a quick search found it there, and that's also what's indicated in the MSDN documentation.
(If you're used to writing VCL form based apps, you won't have seen this before; the VCL initializes COM for you automatically. You're seeing it now because you're writing a console app.)

embedding python in c++

I created a VCL Application in c++, borland. In my project there is a file where I have implemented embedded python in the methods defined in the same(my application contains a button which calls the method in which embedded python is implemented). when I compile, my build is successful. but when I run my application, and click on the button it shows the run time error : "Access violation at address 1E091375 in module 'PYTHON25.DLL'. Read of address 00000004" . please help.
I have never used Python before.
my program:
#pragma hdrstop
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "Python.h"
#include "Unit1.h"
#include "Unit2.h"
#pragma link "python25_bcpp.lib"
//---------------------------------------------------------------------------
#pragma package(smart_init)
bool callHelloWorld(int intVal)
{
char fName[] = "Hello"; //file name
char cFunc[] = "hello"; //method name
char *pfName, *pcFunc;
PyObject *pName, *pModule, *pDict, *pFunc ;
pfName = fName;
pcFunc = cFunc;
Py_Initialize();
pName = PyString_FromString(pfName);
pModule = PyImport_Import(pName);
pDict = PyModule_GetDict(pModule);
pFunc = PyDict_GetItemString(pDict, pcFunc);
if (PyCallable_Check(pFunc))
{
PyObject_CallObject(pFunc, NULL);
} else
{
PyErr_Print();
}
// Py_DECREF(pModule);
// Py_DECREF(pName);
Py_Finalize();
return 0;
}
Check the return values of PyImport_Import (is the module in the search path?) and PyDict_GetItemString.
If that doesn't help put some trace messages in your app to see where it crashes.
This works for me:
Just delete Py_Finalize()
I read in another site that Py_Finalize has some problems in specific cases such as threading.

Ogre3D shows segfault error

I'm writing a game using Ogre3D and I have a problem.
When I starting program, it shows an segfault error:
*-*-* OGRE Initialising
*-*-* Version 1.7.2 (Cthugha)
Creating resource group Essential
Added resource location '../media/packs/SdkTrays.zip' of type 'Zip' to resource group 'Essential'
Added resource location '../media' of type 'FileSystem' to resource group 'General'
Added resource location '../media/materials/scripts' of type 'FileSystem' to resource group 'General'
Added resource location '../media/materials/textures' of type 'FileSystem' to resource group 'General'
Added resource location '../media/models' of type 'FileSystem' to resource group 'General'
Naruszenie ochrony pamięci [This means segfault]
And i don't know, why...
Code:
#define OGRE_CHANGE1 ((1 << 16) | (1 << 8))
#include "Ogre.h"
#include "ExampleApplication.h"
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#else
#include <iostream>
#endif
class MyApp : public ExampleApplication
{
protected:
public:
MyApp()
{
}
~MyApp()
{
}
protected:
void createScene(void)
{
}
};
#ifdef __cplusplus
extern "C" {
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
MyApp App;
try
{
App.go();
return 0;
}
catch (Ogre::Exception& e)
{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "Exception!",
MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr <<"Exception:\n";
std::cerr <<e.getFullDescription().c_str() <<"\n";
#endif
return 1;
}
}
#ifdef __cplusplus
}
#endif
(Code partly from Ogre Wiki)
resources.cfg:
# Resources required by the sample browser and most samples.
[Essential]
Zip=../media/packs/SdkTrays.zip
# Resource locations to be added to the default path
[General]
FileSystem=../media
FileSystem=../media/materials/scripts
FileSystem=../media/materials/textures
FileSystem=../media/models
and plugins.cfg:
# Defines plugins to load
# Define plugin folder
PluginFolder=/usr/lib/OGRE
# Define plugins
# Plugin=RenderSystem_Direct3D9
# Plugin=RenderSystem_Direct3D10
# Plugin=RenderSystem_Direct3D11
Plugin=RenderSystem_GL
# Plugin=RenderSystem_GLES
Plugin=Plugin_ParticleFX
Plugin=Plugin_BSPSceneManager
Plugin=Plugin_CgProgramManager
Plugin=Plugin_PCZSceneManager
Plugin=Plugin_OctreeZone
Plugin=Plugin_OctreeSceneManager
And - when I comment Plugin=Plugin_CgProgramManager in plugins.cfg... Program works, but I need this plugin. :)
Please help.Thanks in advance.
Compile the program with debugging information included (with GCC, this means make sure the -g option is passed to the compiler).
Run it in a debugger.
When it crashes, you'll get a stack trace.
Investigate if it seems to depend on something you did (or not did, such as a missing initialization), or if it looks like a crash in Ogre3D proper.
If the former, fix it.
If the latter, report it.