FLTK in MSVC needs x11 headers? - user-interface

I'm trying to learn how to use FLTK right now (In MSVC 2008). I got all the the libraries compiled correctly, but when I tried to run this program:
#include "FL/Fl.H"
#include "FL/Fl_Window.H"
#include "FL/Fl_Box.H"
int main(int argc, char *argv[]) {
Fl_Window *window = new Fl_Window(340, 180);
Fl_Box *box = new Fl_Box(20, 40, 300, 100, "Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD + FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show();
return Fl::run();
}
I got this error
1>c:\fltk\fl\xutf8.h(33) : fatal error C1083: Cannot open include file: 'X11/X.h': No such file or directory
I can tell that it is missing x11, but I did a quick google search, and I couldn't find any help on this subject. BTW, I'm running v1.3.0.
Thanks for your time.

I found the answer, add "#define WIN32" before your FLTK includes.

Related

Error while building a static Linux binary (with musl-libc) that includes LuaJIT

I've cloned the LuaJIT git repo and built it with:
make STATIC_CC="musl-gcc" BUILDMODE="static"
Then, I compiled a simple Lua "hello world" script into a C header file:
luajit -b test.lua test.h
test.h:
#define luaJIT_BC_test_SIZE 52
static const unsigned char luaJIT_BC_test[] = {
27,76,74,2,10,45,2,0,3,0,2,0,4,54,0,0,0,39,2,1,0,66,0,2,1,75,0,1,0,20,72,101,
108,108,111,32,102,114,111,109,32,76,117,97,33,10,112,114,105,110,116,0
};
After that, I wrote a simple C wrapper by following the official example, test.c:
#include <stdio.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "test.h"
int main(void) {
int error;
lua_State *L = lua_open();
luaL_openlibs(L);
error = luaL_loadbuffer(L, (const char *) luaJIT_BC_test, luaJIT_BC_test_SIZE, "test") || lua_pcall(L, 0, 0, 0);
if (error) {
fprintf(stderr, "%s", lua_tostring(L, -1));
lua_pop(L, 1);
}
lua_close(L);
return 0;
}
But when I try to build it, it crashes with an error:
$ musl-gcc -static -ILuaJIT/src -LLuaJIT/src -o test test.c -lluajit
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/libgcc_eh.a(unwind-dw2-fde-dip.o): in function `_Unwind_Find_FDE':
(.text+0x1953): undefined reference to `_dl_find_object'
collect2: error: ld returned 1 exit status
It's related to libgcc, so I tried building everything with musl-clang, but still got the same error. Can someone explain what I'm missing here?
Figured it out - I needed to build LuaJIT with TARGET_XCFLAGS=-DLUAJIT_NO_UNWIND like so:
make STATIC_CC="musl-gcc" BUILDMODE="static" TARGET_XCFLAGS=-DLUAJIT_NO_UNWIND
I guess this just disables C++ exceptions support, but I'm not sure what the real implications are. Seems to work fine, for now.

Can´t make Qt, Visual C++2015 and openCV work together in 64bit

I´m having trouble with a very simple console project. I am using latest version of MSVC 2015, openCV 3.2 an Qt 5.71 all in 64bit and windows 10 64bit.
The Qt .pro file is:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
win32 {
INCLUDEPATH += "C:\OpenCV3.2\opencv\build\include" \
CONFIG(debug,debug|release) {
LIBS += -L"C:\OpenCV3.2\opencv\build\x64\vc14\lib" \
-lopencv_world320d
}
CONFIG(release,debug|release) {
LIBS += -L"C:\OpenCV3.2\opencv\build\x64\vc14\lib" \
-lopencv_world320
}
}
and the source code is:
#include <iostream>
#include <opencv2\\core\\core.hpp>
#include <opencv2\\highgui\\highgui.hpp>
#include <opencv2\\imgproc\\imgproc.hpp>
using namespace std;
using namespace cv;
Mat imLena; //<-- INCLUDING THIS LINE MAKE THE PROGRAM CRASH
int main(int argc, char *argv[])
{
cout << "Hello World!" << endl;
return 0;
}
This simple program compiles an run perfectly but when I add de line "Mat imLena;" it still compiles perfectly but crashes when I run it. I am very confused. Any tip, idea or suggestion?

Linking another library from C-library in gwan/libraries results in "undefined symbol" error

I'm trying to use a standard library libuuid inside my C-library file my_uuid.c:
gwan/libraries/my_uuid.c:
#include <uuid/uuid.h>
#pragma link "uuid"
void my_uuid_generate(uuid_t uuid)
{
uuid_generate(uuid);
}
gwan/init.c:
#include <uuid/uuid.h>
#pragma link "uuid"
#pragma link "libraries/my_uuid.c"
int main(int argc, char *argv[])
{
uuid_t uuid;
my_uuid_generate(uuid);
return 0;
}
However, G-Wan fails to start and prints such message:
Linking ./init.c: undefined symbol: uuid_generate
This mustn't be the problem of libuuid installation or non-standard path, because such servlet does work successfully:
#include <uuid/uuid.h>
#pragma link "uuid"
int main(int argc, char *argv[])
{
uuid_t uuid;
char str[256];
uuid_generate(uuid);
uuid_unparse(uuid, str);
printf("%s\n", str);
xbuf_cat(get_reply(argv), "Hello, World!");
return 200;
}
The problem might be due to that G-Wan first loads init.c and then my_uuid.c instead of libuuid, even though I have #pragma link "uuid" in init.c.
Does anybody know how to solve the problem?
Is it considered valid to link other libraries from C-file libraries in gwan/libraries?
I read GWAN's documentation. If you write your own library, you should be able to integrate well with it (treating it as a preexisting library).
myuuid.h
myuuid.c
Then generate your library, by compiling myuuid.c:
libmyuuid.a
Put the library as gwan/libraries/libuuid.a and try it as below.
#include "myuuid.h"
#pragma link "./libraries/myuuid"
int main(int argc, char *argv[])
{
my_uuid_generate();
return 0;
}
You may want to keep an eye on gwan/logs/gwan.log file to see if the link worked. You could also start GWAN server in a terminal, manually, to look at the errors.
The servlet works because you are linking your script directly to an existing library (already compiled code).
The init.c script fails to link because the "#pragma link "libraries/my_uuid.c" library that calls a compiled library does not exist yet (it's still source code).
You should rather use #include "libraries/my_uuid.c" in init.c to have this kind of constructions work.
Interestingly, G-Wan successfully started when I moved #pragma link "uuid" below the #pragma link "libraries/my_uuid.c" in init.c file:
#include <uuid/uuid.h>
#pragma link "libraries/my_uuid.c"
#pragma link "uuid"
int main(int argc, char *argv[])
{
uuid_t uuid;
my_uuid_generate(uuid);
return 0;
}
Definitely, it changed the order in which G-Wan loads libuuid and my_uuid.c. Now it first loads libuuid (with uuid_generate() symbol) and then my_uuid.c (with my_uuid_generate() symbol, which in turn calls uuid_generate()).
Gil, do I correctly understand that currently G-Wan is not designed to provide a controllable order of library loads? Can the G-Wan team consider updating the G-Wan server to load the libraries in a controllable/predicatable order, at least in some extent? I.e. load the dependencies before the dependency users.
For example we should be able to write such code as below and the G-Wan server to load first libuuid, then my_uuid.c, then init.c:
gwan/libraries/my_uuid.c:
#pragma link "uuid"
gwan/init.c:
#pragma link "libraries/my_uuid.c"
(notice no #pragma link "uuid" in init.c)

opencv with visual studio 2010 error

I am trying to build my first opencv application, I added the include directories and the library directories and then added the linking input which is some opencv.lib files after running this code:
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat im = imread("c:/full/path/to/lena.jpg");
if (im.empty())
{
cout << "Cannot load image!" << endl;
return -1;
}
imshow("Image", im);
waitKey(0);
}
but I got this error:
The program can't start because libgcc_s_dw2-1.dll is missing from your computer.
the error list include:
Warning 1 warning D9002: ignoring unknown option '-static-libgcc' c:\Users\Kato\documents\visual studio 2010\Projects\cvtest\cvtest\cl cvtest
I added -static-libgcc to command line additional options but the same error.

Can't Build a simple Cuda Program using Xcode !

I'm using Xcode 3.2 on Mac OS 10.6 to build a very simple HelloWorld program for CUDA
but it fails to build .. any ideas !!!
this is the code :
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUDA/CUDA.h>
__device__ char napis_device[14];
__global__ void helloWorldOnDevice(void){
napis_device[0]='H';
napis_device[1]='e';
napis_device[2]='l';
napis_device[3]='l';
napis_device[4]='o';
napis_device[5]=' ';
napis_device[6]='W';
napis_device[7]='o';
napis_device[8]='r';
napis_device[9]='l';
napis_device[10]='d';
napis_device[11]='\n';
}
int main (int argc, char * const argv[]) {
helloWorldOnDevice<<<1,1>>> ();
cudaThreadSynchronize();
char napis_host[14];
const char *symbol="napis device";
cudaMemcpyFromSymbol (napis_host, symbol, sizeof(char)*13, 0, cudaMemcpyDeviceToHost);
return 0;
}
The error appears at this line
helloWorldOnDevice<<<1,1>>> ();
Expected primary-expression before '<' token !!!!!!
You're compiling your program with gcc coming with Xcode. Should use nvcc compiler instead to compile CUDA code. Normally I would use a Makefile to tell that *.cu to be compiled by nvcc and *.cpp by gcc, then link produced objects to an executable.

Resources