Including Allegro 5 Issue - allegro5

I just installed Allegro 5 from the terminal as outlined here: http://wiki.allegro.cc/index.php?title=Install_Allegro5_From_SVN/OSX#Preliminaries. However, when I try to write a program, it has trouble including allegro.h. I have tried:
#include <"allegro5/allegro5.h">
#include <iostream>
using namespace std;
int main () {
cout<<"foo"<<endl;
}
but I get the following error when I compile (using g++):
foo.cpp:1:33: error: "allegro5/allegro5.h": No such file or directory
I have also tried:
#include <"/usr/local/include/allegro5/allegro5.h">
#include <iostream>
using namespace std;
int main () {
cout<<"foo"<<endl;
}
but I get the following error when I try to compile:
foo.cpp:1:52: error: "/usr/local/include/allegro5/allegro5.h": No such file or directory
I know the file at /usr/local/include/allegro5/allegro5.h exists. I have already tried #include <"/usr/local/include/allegro5/allegro.h"> and #include <"allegro5/allegro.h"> as well all with similar results. I know this is a pretty basic question and I just want to be able to write a program which can successfully include allegro.

The double quotes are erroneous and the file is not correct. It should be:
#include <allegro5/allegro.h>

Related

WinDbg TTD: No trace files were identified from this record session

Trying to record execution of Hello World with WinDbg from store.
WinDbg settings:
Executable path: C:\Users\...\Documents\Visual Studio 2017\Projects\TestApplication\Debug\TestApplication.exe
Output directory: c:\Users\...\Documents\
Code:
#include "stdafx.h"
#include "iostream"
using namespace std;
int main()
{
std::cout << "Hello World!\n";
return 0;
}
Error:
TTD: No trace files were identified from this record session
The debugging session could not be started: Path cannot be null.
Parameter name: path
Why it's does not work? What I am missing?
Occasionally TTD recording has trouble creating TTD files to paths with spaces. Recommend entering or pointing Output Directory to save TTD files to a path with no spaces.

Why can't #Include work?

Why does this not work?
#Include D:\Data\Download\Scripts Latex2Unicode.ahk
It says
Include file "D:\Data\Download\Scripts Latex2Unicode.ahk" cannot be opened. The program will exit.
It isn't different from the help page.
Probably you mean:
#Include D:\Data\Download\Scripts\Latex2Unicode.ahk
presuming the directory is "Scripts" and the file name "Latex2Unicode.ahk"
Let us know . . .
EDIT: Note, in the Help example:
#Include C:\My Documents\Scripts\Utility Subroutines.ahk
the file name is "Utility Subroutines.ahk" in the "Scripts" directory -- the directory is not "Utilities" and the file name is not "Subroutines.ahk"

"Failed to open X display" when trying to run project from within Eclipse

I have a simple OpenGL/GLFW test program in Eclipse
#include <iostream>
#include <string>
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
void errorCallback(int error, const char *description)
{
std::cerr << description << " (GLFW error " << error << ")" << std::endl;
}
int main(int argc, char **argv)
{
int returnValue = 0;
try {
// Initialise GLFW.
glfwSetErrorCallback(errorCallback);
if(!glfwInit()) throw std::string("Could not initialise GLFW");
/* ...do everything else... */
} catch(std::string const &str) {
std::cerr << "Error: " << str << std::endl;
returnValue = 1;
}
return returnValue
}
However, running it causes the following to come up in the console:
X11: Failed to open X display (GLFW error 65542)
Error: Could not initialise GLFW
i.e. it fails during glfwInit() (I commented out all the code just to make sure it doesn't actually happen during window creation or something). However, navigating to the build directory (using my file manager, not Eclipse, that is) and manually launching from there works just fine.
Anyone know what the problem could be?
Sounds to me like Eclipse clears all or some of the environment variables when launching the program. The environment variable DISPLAY tell the program how to connect to the X11 server. Without that information it can't open the display, giving you that error.
Simple test to verify this: Add the following like right before glfwInit() (never mind that this is not C++ and doesn't use iostream, but that's okay for a quick test:
fprintf(stderr, "DISPLAY=%s\n", getenv("DISPLAY"));
You must include the headers stdio.h and stdlib.h.
Eclipse indeed wasn't passing any environment variables to my program (thanks datenwolf for getting me started). It's possible to select which environment variables to pass to the program by going to Run Configurations, selecting the appropriate launch configuration under "C/C++ Application" (I only had the default one), opening the Environment tab and then hitting the select button (it lists all available environment variables) and picking which ones you want.

boost_python import error: module does not define init function

First off: I looked at the related questions, but they are not very helpful unfortunately. I'm trying to wrap an enum and a class from an external library.
#include <Python.h>
#include <boost/python.hpp>
using namespace boost::python;
#include <libvpsc/rectangle.h>
using vpsc::Rectangle;
using vpsc::Dim;
BOOST_PYTHON_MODULE(adaptagrams)
{
enum_<Dim>("dim")
.value("x", vpsc::XDIM)
.value("y", vpsc::YDIM)
.value("unset", vpsc::UNSET)
;
class_<Rectangle>("Rectangle",
init<double, double, double, double, optional<bool> >())
.add_property("centerX", &Rectangle::getCentreX)
.add_property("centerY", &Rectangle::getCentreY)
.add_property("width", &Rectangle::width, &Rectangle::set_width)
.add_property("height", &Rectangle::height, &Rectangle::set_height)
;
}
and compile with:
g++ -fPIC -I/usr/include/python2.7 -c adaptagrams.cpp -o adaptagrams.o
g++ -shared -Wl,-soname,adaptagrams.so -o adaptagrams.so adaptagrams.o -lpython2.7 -lboost_python -lvpsc
However, when I try to import the .so module, I get an error:
ImportError: dynamic module does not define init function (PyInit_adaptagrams)
Any ideas?
Update: When I restart Python and try the import, the first error I get is:
ImportError: ./adaptagrams.so: undefined symbol: _ZN8topology13computeStressERKSt6vectorIPNS_4EdgeESaIS2_EE
When I try it again, the 2nd one is the dynamic import from above (2.7) and a segfault (3.2). Boost is compiled against both 2.7 and 3.2 and I am linking the right ones on each approach.
Update 2: The tutorial code from the boost_python page works:
#include <Python.h>
#include <boost/python.hpp>
using namespace boost::python;
struct Hello
{
Hello(std::string msg): msg(msg) {}
void set(std::string msg) { this->msg = msg; }
std::string greet() { return msg; }
std::string msg;
};
BOOST_PYTHON_MODULE(constructor)
{
class_<Hello>("Hello", init<std::string>())
.def("greet", &Hello::greet)
.def("set", &Hello::set)
;
}
Same compilation:
g++ -fPIC -I/usr/include/python2.7 -c constructor.cpp -o constructor.o
g++ -shared -Wl,-soname,constructor.so -o constructor.so constructor.o -lpython2.7 -lboost_python
The name used in BOOST_PYTHON_MODULE must match the name of the .so library you generate and import into python.
I have seen this exception before. I got it using Visual Studio on windows, so things might be a little different over in unix-oid land but:
Two Possibilities:
Debug/Release miss-match:
You are trying to import a debug build of your module into a release build of python (or vice-versa). The solution is to include boost/python/detail/wrap_python.hpp instead of Python.h. This will fix some includes and defines to make it possible to do what you want.
Python/Boost.Python version miss-match:
Boost.Python is compiled against one specific version of python. You are using it with a different version. For example: you seem to be using python 2.7. Your boost_python library might be compiled against python 2.6. Yes, this means that your module can only work with one version of python at a time.
In addition to the other answers (in case another unfortunate soul runs unto this), make sure you're not accidentally compiling with the -fvisibility=hidden flag.
Doing so seems to strip the init function from the binary in both g++ / clang++.
Background info
In my case I had some trouble integrating some wrappers made with Boost.Python into a project. When built with the project's build-system I'd get the same runtime-error as OP (as opposed to building it with my proof-of-concept Makefile where it worked just fine).
Comparing the symbol tables with nm -g foo.so | grep Py showed me that in the non-working case the PyInit_* function was completely absent. Doing some comparison between compilation flags led me to -fvisibilty=hidden being the culprit.

PQescapeLiteral not defined?

This is about the most basic libpq example I could think of to illustrate my problem. The goal here is just to print out the escaped string.
#include <iostream>
#include <libpq-fe.h>
#include <string.h>
using namespace std;
int main(){
PGconn *db;
char connstring[] = "dbname=TheInternet";
db = PQconnectdb(connstring);
char url[] = "http://www.goo'gle.com/";
cout<<PQescapeLiteral(db, (const char *)url, (size_t) strlen(url))<<"\n";
}
When I compile with:
g++ PQescapeLiteral_test.cpp -lpq
or even with:
g++ PQescapeLiteral.cpp -I/usr/include/pgsql:/usr/include/pgsql/server:/usr/include/pgsql/server/libpq -lpq
I get the error:
PQescapeLiteral.cpp: In function ‘int main()’:
PQescapeLiteral.cpp:12: error: ‘PQescapeLiteral’ was not declared in this scope
I found PQescapeLiteral in the manual for pgsql 9.0 in section 31.3.4.: Escaping Strings for Inclusion in SQL Commands. I have the most recent version of libpq and libpq-devel from yum so I'm pretty sure it's supposed to be defined.
If someone can point me in the right direction I'd appreciate it.
It works fine for me, with PostgreSQL 9.0.1 headers. Which version of the postgresql headers and library are you using? PQescapeLiteral was apparently added in 9.0: http://developer.postgresql.org/pgdocs/postgres/release-9-0.html#AEN104548
Where are you expecting libpq.so to be? You show a compiler command with -I switches to locate the headers files in a non-standard location, but no corresponding -L switch to locate the libary.