Unable to Build Boost.python in Visual Studio 2008. Compilation gives error - visual-studio

I am in a HUGE depression now! I spend 2 days trying to use boost.python . PLEASE guide me! I will explain what I did.
I have Winows 7 64 bit.
The Python is 64 bit 2.7.3 installed at C:\Python27_amd64.
Now, I take boost_1_54_0.zip and unzip in F: directory.
The I use cmd.
bootstrap
this creates project-config.jam. I edit it and insert
using msvc : 9.0 ;
using python : 2.7 : C:\Python27_amd64\python : C:\Python27_amd64\include : C:\Python27_amd64\libs ;
Now i do
.\b2
This process runs for 20 something minutes and I am told that boost has successfully been build.
After that I install boost binaries from http://sourceforge.net/projects/boost/files/boost-binaries/
The binaries get installed in C:\local\boost_1_54_0.
Now I want to create a General project.
Now, I use the code given for embedding python in C++ here
#include <boost/python.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
namespace py = boost::python;
using namespace std;
int main()
{
// Initialize the interpreter
Py_Initialize();
py::object main_module = py::import("__main__");
py::object main_namespace = main_module.attr("__dict__");
py::exec("print 'Hello, world'", main_namespace);
py::exec("print 'Hello, world'[3:5]", main_namespace);
py::exec("print '.'.join(['1','2','3'])", main_namespace);
}
I setup the header files and library in VC++ directories to F:\boost_1_54_0\boost_1_54_0 and F:\boost_1_54_0\boost_1_54_0\stage\lib respectively.
I also setup project-->properties-->configuration properties-->C/C++-->General-->Additional Include directories to C:\Python27_amd64\include
Likewise, I also setup project-->properties-->configuration properties--> Linker--> General to C:\Python27_amd64\libs;"C:\local\boost_1_54_0\lib64-msvc-9.0" .
Now when I compile using x64 debugger. It gives me an error
Unhandled exception at 0x00000000 in test8.exe: 0xC0000005: Access violation at location 0x0000000000000000.
I am struck since last 2 days...but thats the closest I have been since then. please help me!

So you mean a runtime error, right?
I think you should first ensure, that there is no exception thrown by boost::python itself.
First try to set the try block around you python calls with a catch(...)
If exception is caught it is most probably the boost::python::error_already_set exception.
So, you then should decode it like here

Related

Recursive include of files in OpenCL source under Xcode

I'm looking to build a host program calling OpenCL code running on my GPU device. The cl source has the following form:
#include "skip_mwc.cl"
typedef struct{ uint x; uint c; } mwc64x_state_t;
//blah...
If I get rid of the #include directive and copy/paste the content of "skip_mwc.cl" directly into this source, I can partially "build" and at least get some errors, showing that my compiler (clang9 cl compiler) can at least recognize the kernels code. With the #include approach I get the following error:
Build log::
<program source>:9:10: fatal error: 'skip_mwc.cl' file not found
#include "skip_mwc.cl"
I have checked and the file is there in the search paths, so I'm inclined to believe that my Xcode IDE doesn't index .cl files properly to perform automatic file inclusion (as in .c or .cpp).
I really want to avoid having to copy/paste source from one file into the other. Any suggestions from someone familiar with Xcode, who has encountered this problem and managed to solve it, are very welcome and needed.
Thanks,
A
Two possible solutions:
Set the -I include_dir compiler option in clBuildProgram(), see also this answer.
Read both files from C++ with fstream and string-concatenate their content.
Also see the option of embedding the OpenCL code into the executable via stringification macro.

Win32: Error with CreateTextServices

I'm trying to use CreateTextServices function in TextServ.h. It seem I have to link riched20.lib to project to use this function.
But when I add riched20.lib to Linker/Input/Additional Depedencies, VS say error LNK1181: cannot open input file 'riched20.lib'.
How to fix this error?
I'm using VS 2013, Win 8.1 32 bit.
Had the same issue. I think there's no lib available for recent versions of richedit/msftedit, but textserv.h provides a definition of the function, so what you can do without any need for an extra .lib is this:
// load the dll and get the function address
// PCreateTextServices is declared in textserv.h:
HMODULE h = LoadLibrary(L"msftedit.dll");
PCreateTextServices createTextServices = (PCreateTextServices)GetProcAddress(h, "CreateTextServices");
...
ITextServices svc*;
int hr = createTextServices(NULL, host, (IUnknown**)&svc);
...
svc->Release();
FreeLibrary(h);

QT 5.2 app cannot start (Bad allocation error) when Qt5Core.dll is in app directory

I have a funny problem on my machine
Windows 7 x64, using QT 5.2 for the GUI
I'm not able to start the app I always receive the error
First I thought I had a broken dll, so through some trial and error I found a solution:
I add the QT5Core.dll via enviroment path, and NOT directly to the app folder. Then the programm works. If I copy the dll back to the app Folder, Same problem as before!?!?!?1
I'm really confused, because the error only occurs on my machine?
Debugging doesn't really help,
In code, the error occures here:
MyApplication::MYApplication(int argc, char** argv, int version)
: QApplication(argc, argv, version) // <<< this call fails!
{ }
somebody can help me?
Why is the location of the qt5core.dll a problem?!?!?
UPDATE
I used the profiling function of depends and found the following behaviour:
Failing
GetProcAddress(0x76800000 [c:\windows\syswow64\KERNEL32.DLL], "CreateSymbolicLinkW") called from > "dirone\xxxx.EXE" at address 0x00FF2877 and returned 0x7688CCE9.
First chance exception 0xE06D7363 (Microsoft C++ Exception) occurred in "c:\windows\syswow64\KERNELBASE.DLL" at address 0x765CC41F.
Exception: "bad allocation"
Working
LoadLibraryW("C:\BuildPackages\QT\plugins\platforms\qwindows.dll") called from "dirtwo\QT5CORE.DLL" at address 0x66AA5154.
Loaded "c:\buildpackages\qt\plugins\platforms\QWINDOWS.DLL" at address
0x0F380000. Successfully hooked module.
somehow the path to the qwindows.dll is hardcoded into the dll (there is no environment path to this directory)
If I rename the qwindows.dll or delete it, startup failes again.
BUT the qwindows.dll is bundeld with our product. It is in a subdirectory ./platforms/
AND the files are the same (diff returns equal)
Somebody have some clue what I should try next?
Check if you already have some qt related environmental variables.
Crashes are usually due to this, remove those envronmental variables first. Check whether you have any other qt installed libraries.
it would be better if you can post the cal stacks.
Some other dlls are needed that reside in the directory of the qt5core.dll. When you add this path to the search path the dlls are found. When you simply copy the dll these dlls can not be found. You can check dependencies with the depends tool.
Candidates for the additional dlls are:
icuin51.dll and icuuc51.dll
Found the Problem:
The enviromentvariable:
QT_QPA_PLATFORM_PLUGIN_PATH=C:\BuildPackages\QT\plugins\platforms
was set to the path. If removing this variable, everything works as it should!

F# Microsoft.ParallelArrays not defined

So I downloaded and installed Microsoft Accelerator v2 to use ParallelArrays. I have referenced it in my project but when I try and execute the code from the module in a script file I get:
"The namespace 'ParallelArrays' is not defined
I have followed the instructions on this post:
Microsoft Accelerator library with Visual Studio F#
I've added a reference to the managed version "Microsoft.Accelerator.dll" to my F# project and then added the native "Accelerator.dll" as an item in my solution and set it's 'Copy To Output Directory' to Copy Always.
Still getting the FSI error and inline error in my script file on the '#load ...' line, however the solution builds fine, and no error in the module file.
Any ideas on what I'm missing? I'm sure it's something stupid.
Thanks,
Justin
UPDATE
I tried mydogisbox's advice, which got rid of the error above, but now when I run the code in the .fsx file I get this error instead:
--> Referenced 'F:\Work\GitHub\qf-sharp\qf-sharp\bin\Debug\Microsoft.Accelerator.dll' (file may be locked by F# Interactive process)
[Loading F:\Work\GitHub\qf-sharp\qf-sharp\MonteCarloGPU.fs]
error FS0192: internal error: F:\Work\GitHub\qf-sharp\qf-sharp\Accelerator.dll: bad cli header, rva 0
UPDATE 2
So the bad header error has dissapeared, but now I get this instead:
Microsoft.ParallelArrays.AcceleratorException: Failure to create a DirectX 9 device.
at Microsoft.ParallelArrays.ParallelArrays.ThrowNativeAcceleratorException()
at Microsoft.ParallelArrays.DX9Target..ctor()
at <StartupCode$FSI_0002>.$FSI_0002_MonteCarloGPU.main#() in F:\Work\GitHub\qf- sharp\qf-sharp\MonteCarloGPU.fs:line 14
Stopped due to error
I found this thread on MSDN however the answers proposed as fixes on that thread barely even relate to the question.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/98600646-0345-4f62-a6c5-f03ac9c77179/ms-accelerator?forum=csharpgeneral
My Direct X version is 11, and I imagine that will suffice, however I tried installing DX9 however, it tells me that a newer version is detected therefore cant install.
There are special directives for referencing dlls from fsi. The #load directive loads the .fs file only. You need to use the #r directive to reference the file. You can either use the full path of the file or you can use #I to include the path to the file. More details here. Keep in mind that fsi is completely independent of your project, so all references in your project must be duplicated in fsi for it to access the same types.

Error 3 error LNK1104: cannot open file 'gtk-3.lib'

I have been trying to get GTK 3.0 to work, and have followed all the steps here
How to configure gtk on Visual studio 2010
And changing to 3.0 where needed to get GTK to work, and it seems to have loaded everything it needs in order to compile, but it gives me the error
Error 3 error LNK1104: cannot open file 'gtk-3.lib'
Whenever I try to run the program.
I am using visual studios 2012, but this was the only place i found anything about getting GTK to run on any visual studios.
Here is the code I am using:
#include <gtk-3.0\gtk\gtk.h>
int main(int argc, char* argv[])
{
gtk_init(&argc, &argv);
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//gtk_widget_get_preferred_size(window, 300, 200);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_window_set_title(GTK_WINDOW(window), "GTK+ with VS2010");
gtk_widget_show(window);
gtk_main();
return 0;
}
I commented out the gtk_widget_get_prefered_size call because it is irrelevant to the problem
any suggestions? I've looked in several places but none came up with clear answers.
The library gtk-3.lib does not exist. In fact, the library reference is not required to build your GTK 3 application. The pkg-config helper doesn't seem to generate the correct linker flags needed to link your application.
Just add in your Additional Options area all the existing libraries found in your GTK package (\gtk3\lib). The lib files for my bundle (gtk+-bundle_3.6.4-20130921) were as follows:
atk-1.0.lib cairo.lib fontconfig.lib gailutil.lib gdk-win32-3.0.lib gdk_pixbuf-2.0.lib gio-2.0.lib glib-2.0.lib gmodule-2.0.lib gobject-2.0.lib gthread-2.0.lib gtk-win32-3.0.lib pango-1.0.lib pangocairo-1.0.lib pangoft2-1.0.lib pangowin32-1.0.lib
(or you can go to your library path via a command prompt and enter dir *.lib /B)
Don't forget to include the /ENTRY:mainCRTStartup flag mention in the initial answer you started with.
you may have to edit your project settings or use a pragma comment to link with your gtk library:
#pragma comment(lib, "gtk-3")//if the libray is on your project's path
#define PATH "C:\\example\\"
#pragma comment(lib, PATH"gtk-3")//if the library is on PATH

Resources