opengl + glew in Eclipse (for windows) - eclipse

I'm trying to get glew to work under eclipse (mingw) in windows. Seems as if it is extremely unusual not to use Visual Studio in this context. The install instructions for glew is simply "use the project file in build/vc6/"...
The glew readme also writes:
"If you wish to build GLEW from scratch (update the extension data from
the net or add your own extension information), you need a Unix
environment (including wget, perl, and GNU make). The extension data
is regenerated from the top level source directory with:
make extensions"
In order to get glew to work in eclipse and windows I have to compile it in a unix environment? Is there no other way?
Sure, it would probably be a learning experience to pull that off (if I were to succeed) but I feel that my time is best spent actually working on my project. And even if I did manage to crosscompile everything, would it work in anything but Visual Studio?
Is the whole thing unfeasible and the best solution is to install Visual Studio?
Google haven't been of much help, I feel like I am the only one that has ever attempted to do this (is there a good reason this?).

Well if you still require some flexibility that the VS compiler doesn't always hold, you could try downloading the glew source zip file (on their main sourceforge page). Saying you have to have a Unix environment in order for it to work with eclipse is a huge mistake, as I have it working with MinGW at the moment. Just download the source, extract it, and create/put this batch file into the directory with "Makefile":
#echo on
set SYSTEM=mingw
set GLEW_DEST=C:\...[where you extracted it to]...\glew-1.7.0\usr
path = %PATH%;C:\MinGW\msys\1.0\bin;
make all
make install.all
pause
Change ...[where you extracted it to]... to the path you extracted the downloaded source zip to. Save that and run it, and you should see a "usr" folder containing all the dlls, libs, and headers you'll need. Copy those over to their respective OpenGL counterparts (or just anywhere where you'll be able to specify them in Eclipse later).
Now, in Eclipse, make a new project and at least be sure to include this somewhere:
#ifndef GLEW_STATIC
#define GLEW_STATIC
#endif //GLEW_STATIC
#include <Windows.h>
#include <GL/glew.h>
#include <GL/wglew.h>
If you put the glew headers somewhere besides the OpenGL headers, you may not have to use GL/. Now include the libraries by going into Project->Properties->C/C++ Build->Settings->Tool Settings->MinGW C++ Linker->Libraries and add the following libraries:
glew32
opengl32
glu32
glew32.dll
Add any library search paths you'll need. In my case I just used "C:\MinGW\lib" as a second measure.
Now save all your project files, use Project->Clean..., and build your project. If you don't get any glew errors and your project is prepared you should be able to run it.
Hope that works! It did for me.

Try the following:
Download the Windows 32-bit binary for GLEW here: http://glew.sourceforge.net/index.html
Follow the instruction to link your project to GLEW: http://glew.sourceforge.net/install.html
Make sure your Eclipse is also setup to compile with mingw. (I assume you've done this.)
cout << "Hello world!";

Related

How to generate the plugin of "Li2018" in Halide on windows and exploit "load_plugin" in other project?

reccently, I want to test how does the autoscheduler "Li2018" work on GPU. Firstly, I need to load the plugin of this autoscheduler into my project with function "load_plugin("gradient_autoscheduler")" like the example: https://github.com/halide/Halide/blob/master/apps/gradient_autoscheduler/test.cpp but the biggest problem is, that I cannot generate the plugin on Windows. I have tried to add the "generate_autoscheduler" into the CMakeList.txt in the /apps folder, but it can not work. To compare with autoscheduler "Admas2019" which in the folder /apps/autoscheduler, "Li2018" need a CMakeList.txt to generate the dll plugin, Does some one know how to generate the plugin of "Li2018" on windows? Thanks in advance!
As you have noticed, we don't have a CMake configuration for Li's autoscheduler, so Windows is not supported yet. I'll put this in my TODO list, but contributions are always welcome. It shouldn't be hard to come up with a CMakeLists.txt based on the Makefile content.

In Adacore's GPR file, how can I set the compiler include search paths for C++

I have some C++ code that I need to compile using Adacore GNAT Programming Studio.
One file (SomeHeader.h) is in a Common directory (../../Common/) relative to my GPR file.
Our convention for C++ include directives is to use
#include "Common/SomeHeader.h"
No matter what I do, I cannot get GprBuild to find "Common/SomeHeader.h"
I followed the instructions here at AdaGem 108 with modifications for C++
for Include_Switches ("c++") use ("-I ../../");
and
for Include_Path ("c++") use "../..";
None of this seems to work for me during gprbuild and frustratingly I can't seem to get at the backend command that gprbuild is using even after turning the build verbosity up.
I see some temp files in the build messages but they get deleted before I can access them.
I am using Adacore GPS 17.1 on Windows 10 i686-pc-mingw32, GNAT Pro 17.1.
Does anyone know how to get include search paths working in Adacore's Gprbuild?
If you want to use relative paths, and you are dead set on using the -I flag, be aware that the current directory at the time you compile your c++ code it is set to the obj directory configured for grp.
So if the directory you want to include is located at C:\Foo\Bar\src\include\ and your grp obj directory is at C:\Foo\Bar\env\gpr\obj then your relative path will need to use -I..\..\..\src\include
I haven't tried to use gprbuild for compiling C++ source text yet, but I suppose it works more or less like with Ada, where you add the relevant directories to the Source_Dirs attribute:
project Cookie is
for Languages use ("C++");
for Source_Dirs use (".",
"../..");
[...]
end Cookie;

How to get Google Protobuf working in Matlab?

So if one was to want to use Google protocol buffers in Matlab and using a Windows computer what would be the best way to do that since Matlab is not in the list of supported languages?
I haven't seen an answer on this and I thought the solution was a bit obscure so I am going to post a how to for matlab_out using the protoc.exe
A how to for google protocol buffer matlab out, this is using resources from the internet I will also include a zip file containing all this already done.
Unzip protobuf-‘version#’.zip (looks like: protobuf-#.#.#)
Open file protobuf-#.#.# -> src
Choose your favorite editor (Notepad++ is good) and change Makefile.am (do not include quotes)
a. Under “nobase_include_HEADERS =”
and below “$(GZHEADERS)”
add the line “farsounder/protobuf/compiler/matlab/matlab_generator.h \” (Note the back slash)
b. Under “libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la”
add lines
“farsounder/protobuf/compiler/matlab/matlab_generator.cc \”
“farsounder/protobuf/compiler/matlab/matlab_plugin.cc \”
c. Save the file and exit out
While still in the src directory go into ->google ->protobuf->compiler and change main.cc
a. Under “#include <google/protobuf/compiler/java/java_generator.h>”
add the line “#include <farsounder/protobuf/compiler/matlab/matlab_generator.h>”
b. In main function add the lines
“// Proto2 Matlab
farsounder::protobuf::compiler::matlab::MatlabGenerator matlab_generator;
cli.RegisterGenerator("--matlab_out", &matlab_generator,
"Generate Matlab M files.");”
c. Save the file and exit out
Unzip protobuf-matlab
Open file protobuf-matlab ->src and copy the farsounder directory to protobuf-#.#.# -> src directory
Go back to protobuf-#.#.# directory and into -> vsprojects and open protobuf.sln in Visual Studio, I believe any version should work
There should be a popup that wants to convert the solution file to a more updated version, go ahead and do that
If you do not see solutions explorer open it up using ctrl+alt+L
Open a new windows explorer and go into protobuf-#.#.# ->src->farsounder->protobuf->compiler->matlab, now in visual studio using the solutions explorer expand the libprotoc->Header Files, now in windows explorer copy the matlab_generator.h file and paste it into the Header Files directory
Still in Solutions explorer go into the Source Files directory and copy in the matlab_generator.cc
Contract libprotoc and right click on protoc and click on properties
Under Configuration Properties->Linker->General, Edit Enable Incremental Linking to be No
Under Configuration Properties->Linker->Input, Edit Additional Dependencies
a. Add the lines “Release\libprotobuf.lib” and underneath “Release\libprotoc.lib”
b. Click OK on the Additional Dependencies window and OK on the protoc Property Page
Change the build type to Release
Right-click on libprotobuf and select build, once completed right-click on libprotoc and select build
Once completed right-click on protoc and select build, it should provide you with an protoc.exe under protobuf-#.#.# ->vsprojects->Release, this will now allow you to create matlab .m files by using the matlab_out command
Help to find protobuf-#.#.# and the protobuf-matlab:
Follow these links:
https://code.google.com/p/protobuf-matlab/source/browse/
download the zip file
https://github.com/google/protobuf/releases
download the source code
Extra help, for using protoc.exe
Copy and paste the created protoc.exe to where your .proto file is
Run cmd and change the directory to where your protoc.exe and .proto file is
Run this command (lets pretend the name of my .proto file is “afunprotofile”) “protoc –matlab_out=./ -I./ afunprotofile.proto”
The easiest way is to use Java
The FarSounder code was nice, but it is quite old and unmaintained. The easiest way to produce Matlab compatible code is to just use the Java version of Protobuf. This solution should work on any platform that supports Matlab and Java.
The Steps
Create a .proto file
Process the file with the protoc compiler and output Java source
Using IntelliJ or other tool produce a JAR file that includes the dependencies
Add the JAR file to the Matlab classpath. edit('classpath.txt')
Restart Matlab
The protobuf runtime dependencies
I include these in a single JAR file output of the Protobuf and the two runtime libraries.
protobuf-java-3.3.0.jar
protobuf-java-util-3.3.0.jar
A sample
I wrote a simple Java wrapper class to hide the MyProtobuf.Builder return type from Matlab that I added to the JAR file
public class MyProtobufWrapperWrapper {
public static MyProtobuf.Builder newBuilder()
{
return MyProtobuf.newBuilder();
}
}
In Matlab
p = com.cameronpalmer.MyProtobufWrapper.newBuilder();
p.setIdentifier(java.util.UUID.randomUUID().toString());
p.setTimestampMilliseconds(timestamp);
p.setAngleRadians(0);
p.addAllChannelSamples(channel_vector);
planeWaveBuilt = p.build();
byteArray = planeWaveBuilt.toByteArray();
As Cameron Lowell Palmer's answer suggests, the way to go is via Java.
Is I lost a couple of hours today on this problem, I would like to elaborate some more. I started with Cameron's answer but I had to do a couple of more steps. Essentially, I had to do all of the following:
Compile proto message for java, e.g. protoc --java_out=./ your_file.proto
Remember to install protobuf java runtime, e.g. in ubuntu: sudo apt install libprotobuf-java
Locate the protobuf java runtime on your system, e.g.: /usr/share/java/protobuf-3.6.1.jar; its path will be used later on. The name should always follow the pattern protobuf-version.jar or protobuf-java-version.jar, therefore locate protobuf- | grep jar$ should reduce the search space for you.
Add a short java file to the same directory, where your protobuf java files went (./x/y/z/MyProto.java). Use your package path instead of x/y/z. If you did not declare java package explicitly in the proto file, then protoc just used your filename as package name. Either way, you can probably check where the protoc generated files went by yourself. Contents of MyProto.java are listed below. Just replace YourProtoFileName and YourMessageName with your stuff. Note that this step is not optional, as this will not generate a simple helper class. For the life of me, Matlab would not let me use inner classes directly (in java, YourMessageName is the inner class of YourProtoFileName). But with the above helper, it was quite happy to generate them for me. Note that if you have more than one message defined in your proto file, you might need to expose more than one builder in this way. And if you only need to read protobuffers, then you might need to export just YourMessageName and not Builder.
package x.y.z;
import x.y.z.YourProtoFileName; // if you do not know it, do `ls x.y.z/*.java`
public class MyProto {
public static YourProtoFileName.YourMessageName.Builder newBuilder() {
return YourProtoFileName.YourMessageName.newBuilder();
}
}
Check Matlab's version of java; in Matlab write version -java. In my case it was 1.8, while the default java installed on my system (java -version) is 11. I had to manually select java 1.8 for the next step, otherwise the whole thing did not work. Even worse, Matlab only produced a very nondescript error "No class x.y.z.YourProtoFileName." Thanks Matlab! You might need to install proper version first (sudo apt install openjdk-8-jdk) and then use update-java-alternatives or just locate javac for the appropriate java version on your system.
Compile both your java file and the one generated by protoc. Remember to point classpath at the jar file or protobuffer runtime that you found above. And remember to use your javac path. In a single command: /usr/lib/jvm/java-8-openjdk-amd64/bin/javac x.y.z/*.java -cp /usr/share/java/protobuf-3.6.1.jar. This will generate class files in ./x/y/z/.
Optional: pack the class files in a jar for easier distribution: jar cvf ./YourProtoFilename.jar x/y/z/*.class. Note that this command line works for me, since I've put all classes, including MyProto, in the same package. You might need to adapt it to your needs.
Start Matlab.
% make Matlab aware of your new classes
javaaddpath('./')
% tell Matlab where protobuf dependancy lives (use the path from step 3)
javaaddpath('/usr/share/java/protobuf-3.6.1.jar')
% test if the classes were found
methods('x.y.z.YourProtoFilename.YourMessageName')
% if methods are listed then you are good to go
% use the helper form step 4
b = x.y.z.MyProto.newBuilder();
% now you have a builder you can use to build your protobuf message
See Google's protobuf java primer to go on from here, as using java in Matlab is fairly straight forward: just write java statements. As long as they are simple statements :)
The same procedure works on octave too. With a bit different syntax for java inside octave. And octave was less picky about the java version in my case. YMMV
#WPFUser,
We followed below steps to build protoc for matlab.
1) git clone https://github.com/protocolbuffers/protobuf.git to protobuf-main folder
2) git submodule update --init --recursive
3) git clone https://github.com/farsounder/protobuf-matlab.git - protobuf_matlab folder
4) Copied src folder from protobuf_matlab repo to protobuf-main/src
5) Updated cmake/libprotoc.cmake to include matlab_generator.cc and matlab_generator.h files
6) Updated cmake/extract_includes.bat.in to include matlab_generator.h file
7) \src\google\protobuf\compiler\main.cc to include matlab_generator

Eclipse c++ with mingw comiler cant build boost regex example, can find .a library files

I'm trying to build the boost regex example in eclipse using mingw on vista.
I built boost ok with mingw as there are library files XXXX.a.
I could build/compile the first boost example that doesnt require any of the compiled boost libraries.
When I compile the regex example I get a linker error saying it cant find the library file.
I have tried various libray file names eg leave off the .a extension, leave off the lib prefix etc.
Now the interesting thing is that if I leave off the library extension and rename the library file to XXX.lib it works and runs ok.
So why cant it read the .a library file?
It must be my setup somewhere but I dont know where or what to set.
From what I read everyone is ok linking the .a file except me :(
Thanks in advance,
Kim
Is this similar to this thread?
I built the stock Hello World with no problems and added a second "utilities" static library project for practice. I did the following:
checked "utilities" as a project reference for Hello World.
added libutilities as as a lbrary to "Hello World" project library list.
added "${workspace_loc:/utilities/Debug}" as the dir path for libs. (libutilities.a lives there). (also tried the "file system" version of this.)
Clean and build results in the following error:
g++ -LC:\projects\fargo\utilities\Debug -ohello_world.exe src\hello_world.o
src\c_template_class.o -llibutilities
C:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe:
cannot find -llibutilities
collect2: ld returned 1 exit status
To link a library libutilities.a, the command line option should be -lutilities

How do I build project files and packages for Borland C++ Builder 5 from the command line?

How do I build Borland C++ project files (bpr) and package files (bpk) from the command line? Project groups (bpg) are apparently make files and can be compile with make. But bpks and bprs are xml based and the Export to Makefile won't compile with make.
If I put a project in a bpg, make can't seem to find any of the files specified in the bpg since they all appear to be relative references. I changed the references to absolutes and make reports:
Fatal: Unable to open makefile
You don't need to directly compile a bpr. Just create a bpk which just includes that single bpr, and you can use make to compile it.
"c:\program files\borland\cbuilder5\bin\make" -B -s -fabc.bpg
If you also have other borland compilers installed, do not call the make.exe from the other compiler.
EDIT: execute the make command in the directory where the bpg and bpr is located.
Using bpr2mak and make works for me just fine, so as Roger said, you need to give details on what errors you're getting. BPK files can also be processed with bpr2mak. I'm using this method to compile a large project with many components, without difficulties.
Perhaps you could give some more information on 'won't compile'.
I.e. What error messages are you getting.
One frequent problem the come up with make is addressed at the following
http://www.delphigroups.info/3/8/36427.html