|
Jochen gave a full detail but I am going reduce his answer down to make it simpler
gcc -l sets a library file name to link (we are assuming the file is in the library directory chains).
gcc -L Sets the directory for library files.
So the little l is a library file name (so it will be -l cv2 in your case), it's a simple name no folder, no extension.
cv2.so is a shared object file so if the linker can't find it and it's there ... then your big L setting is wrong.
So your big L should be -L /usr/local/lib
Look at the command Eclipse fires out onto the command line and look for those two.
In vino veritas
modified 14-Nov-16 4:48am.
|
|
|
|
|
Thanks to all, I really appreciate your help.
I did some more messing around and managed to input correct -L using / copying stuff affecting ALL projects. It sort off worked.
Than I did -l and typed cv2.so and the linker could not find it.
I'll try just cv2 without the so extension next.
AS I said , there is an GUI option to select "shared" files so as soon as I can get the linker to work I'll play with that.
I just rebuild another "buidl" using CMake again and will see what I messed up this time.
I'll cannot post the linker output until I have it back working after this new Make, sorry.
|
|
|
|
|
Here is what I am getting,
I need to find out what /ld is , maybe that will give me a clue.
And here is a terrible though - how do I verify that OpenCV will work on Unbutu - 32 bits and Eclipse - also 32 bits?
I can run "hello world", but cannot get the linker to work with OpenCV.
**** Build of configuration Debug for project TEST_1 ****
**** Internal Builder is used for build ****
g++ -L/usr/local/lib -shared -L/media/jim/OpenCL/OpenCV/build/lib -shared -olibTEST_1 src/TEST_1.o -l/cv2 -l/cv2.so -l/media/jim/OpenCL/OpenCV/build/lib/libopencv_flann_pch_dephelp.a -l/media/jim/OpenCL/OpenCV/build/lib/libopencv_videoio.so -l/media/jim/OpenCL/OpenCV/build/lib/libopencv_videoio -llibopencv_videoio
/usr/bin/ld: cannot find -l/cv2
/usr/bin/ld: cannot find -l/cv2.so
/usr/bin/ld: cannot find -l/media/jim/OpenCL/OpenCV/build/lib/libopencv_flann_pch_dephelp.a
/usr/bin/ld: cannot find -l/media/jim/OpenCL/OpenCV/build/lib/libopencv_videoio.so
/usr/bin/ld: cannot find -l/media/jim/OpenCL/OpenCV/build/lib/libopencv_videoio
/usr/bin/ld: cannot find -llibopencv_videoio
collect2: error: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 186 ms.
|
|
|
|
|
You only need one of these for cv2
-l/cv2 -l/cv2.so
but as neither is working, try fully qualifying it as a single entry which means use a colon
-l:cv2.so
The reason I think you are having to do that is you have not set GCC command with the -shared cv2.so if you look you have -shared and nothing after it
You have can set the -L directory I don't think the -l command can have directory entries
-L/my/long/directory -lfoo -L/my/other/even/longer/directory -lfoo1
That I believe is how you do library foo & foo1 from different long directories
Edit: I also see above you got the make file sort of working so you must be able to see the actual command lines to the linker.
In vino veritas
modified 14-Nov-16 11:54am.
|
|
|
|
|
Good news,
it linked AFTER I changed the -l to -l:cv2.so
I'll check the GCC linker -l option and try to figure it out.
It seems I should not have to add the .so extension to the file name. But it would not work without it, probably related to -shared option too.
As far as the -shared - it is a common option and I need to find out how it works too.
I beginning to believe the Elipse Settings GUI is not telling the whole story as far as how to use it. There is "Common" window dialog of all the options currently set , but it cannot be edited !
|
|
|
|
|
Yeah sorry I can't help with Eclipse I just put GCC on my external tools menu on Visual Studio 2015
I am too slack to learn another IDE.
In vino veritas
|
|
|
|
|
ld is the linker which collects all the object modules and libraries, and combines them into a new library, or an executable program. The library options to the linker are as follows:
-L followed by a directory path, adds that directory to the list of locations to be searched for any additional libraries.
-l add the undecorated library name to the list of libraries required by the object code. Note that libraries are commonly held in files which are named liblibraryname.suffix, where suffix is .a or .so. However the name specified on the option line should just be libraryname, i.e. no preceing lib and no suffix. And no directory paths.
So the options you should be using for /media/jim/OpenCL/OpenCV/build/lib/libopencv_flann_pch_dephelp.a should be something like:
-L/media/jim/OpenCL/OpenCV/build/lib
-lopencv_flann_pch_dephelp
And it would really make your questions easier to read if you would use <pre> tags as requested many times.
|
|
|
|
|
To nail it down again:
The -l option requires a stripped library name without path, lib prefix, and extension!
When specifying all library pathes with the -L option, it must be just:
-lcv2
-lopencv_flann_pch_dephelp
-lopencv_videoio
The linker (ld) will then search all directories specified with the -L option for matching files by building the full name from the path actually searched, appending the lib prefix, appending the name passed to the -l option, and appending the extension .a . If that fails for a path, it tries again with the extension .so.
|
|
|
|
|
Yes, that is how is SHOULD work per GCC linker.
|
|
|
|
|
And that is how it does work. You just need to ensure that your options and parameters are specified correctly.
|
|
|
|
|
Hi,
I am new to this device driver development field.
I am asked to write a Windows device driver for capturing the kernel system calls for any particular Win32 API call.
For example,
There is one MFC Dialog based application which will call the Win32 API(Ex: CreateFile() with proper arguments)
At the same time the device driver should capture all the Kernel system calls which are called corresponding to the CreateFile() API. Those Kernel system call I need to display on the GUI of my appllication at real time.
Please share any Article or the guide me in acheiveing this.
Any help will be of great help.
Thanks in advance.
|
|
|
|
|
|
|
Thanks Eddy,
I tried to explore WinAPIOverride.
Will this application display Kernel System calls? I doubt. It is showing some addresses in the call stack, but not the actual system calls name. Is is possible to get the names of the kernel system calls?
Thanks in advance.
|
|
|
|
|
|
class CObject
{
public:
bool SetInt(string strPropName,int nValue);
private:
map<string,VARIANT> m_properties;
private:
std::string m_strClassName;
};
for example,If CObject has a "Hello" property,I can set it's value like this:
CObject* pObject = new CObject("switch");
pObject->SetInt("Hello",123);
but It is not very good enough,if I code like this:
pObject->SetInt("Helloooooooo",123);
here,I write the wrong property name ,but the code wouldn't generate any error at compile time.
*******************************************************************
1 there is a lot class defined by string
2 there may be a lot of objects defined by any class
3 there is a lot of properties for each object
My question is how could I avoid the above mistake at compile time?
Thank you all
|
|
|
|
|
One pretty obvious way is make a set of strings of valid property strings
std::set<std::string> s;
s.insert("Hello");
Then all you need to do is use the standard set find call to know if its there
std:string TestCmd = "Hellooooooooo";
if (s.find(TestCmd) == s.end()){
}
Personally I wouldn't use a string for the property it's not going to be fast to enumerate but that is an exact description of what you are asking.
I would do the same as windows use something like a CRC to hash the strings to integer. Much faster to search for an integer ID than a string.
However if you want to google away the question is
"Fastest way to check if a string exists in a set of strings"
In vino veritas
|
|
|
|
|
Thank you
I could check whether a property is in the set or not at run time.
but I want to check it at compile time.
I just write "Helloooooooo" instead of "Hello" by mistake.
I want to find out this mistake when I compile it.
|
|
|
|
|
If you are on a C++11 compiler you are defining a compile time helper function. If you aren't you are dead in the water.
Search "function that accepts only compile time known expressions"
If you are on Visual Studio, I have never played with it but I think you want this.
<type_traits>[^]
In vino veritas
modified 11-Nov-16 1:55am.
|
|
|
|
|
The only way to provoke a compiler error would be to pass the knowledge of the full list of class properties to the compiler, at compile time. That would defeat the purpose of a generic class definition, and you could just as well define simple member variables instead.
This raises the question: where do your requirements come from, i. e the two requirements to define a generic class, and to force compile time errors when accessing an incorrectly labeled property? One of them has to go.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Hello Experts!
There is a certain window, about which we know hDC & hWnd.
By the window is used function SwapBuffer(hDC). I understand that the double buffer, and that buffer contains a certain image that is drawn in the window.
Question!
Is it possible in any way to copy the contents of the buffer to a compatible Bitmap or Image for Saving it into graphic file format?
?
Regards,
Onic777
onic@inbox.ru
|
|
|
|
|
That is all you need .. you can then get the window size
RECT r;
GetWindowRect(hWnd, &r);
int Wth = r.right - r.left;
int Ht = r.bottom - r.top;
You also have the wonderful function CreateDIBSection which just needs a DC
CreateDIBSection function (Windows)[^]
You will need to allocate memory to hold the bits. That size is slightly tricky it depends on what color depth you are going to ask for in bits. Typically you want RGB24 or RGB32 and the size also needs to be aligned to a 4 byte boundary. Anyhow long story short its a funny maths calc and we need to setup a bitmap header info for the call ... Lets do 24 bit colour.
BITMAPINFOHEADER BMIH;
BMIH.biSize = sizeof(BITMAPINFOHEADER);
BMIH.biBitCount = 24;
BMIH.biPlanes = 1;
BMIH.biCompression = BI_RGB;
BMIH.biWidth = Wth;
BMIH.biHeight = Ht;
BMIH.biSizeImage = ((((BMIH.biWidth * BMIH.biBitCount)+ 31) & ~31) >> 3) * BMIH.biHeight;
See that funny calc at end well BMIH.biSizeImage now has the memory size you need to allocate. So allocate it and then call CreateDIBSection
char* myBits = malloc(BMIH.biSizeImage);
CreateDIBSection(hDC, (CONST BITMAPINFO*)&BMIH, DIB_RGB_COLORS, (void**)&myBits, NULL, 0);
myBits now has all your image data from the DC now all you need to do is save it!!!!
For a BMP file that is trivial
FILE *pFile = fopen( , "wb");
BITMAPFILEHEADER bmfh;
int nBitsOffset = sizeof(BITMAPFILEHEADER) + BMIH.biSize;
LONG lImageSize = BMIH.biSizeImage;
LONG lFileSize = nBitsOffset + lImageSize;
bmfh.bfType = 'B'+('M'<<8);
bmfh.bfOffBits = nBitsOffset;
bmfh.bfSize = lFileSize;
bmfh.bfReserved1 = bmfh.bfReserved2 = 0;
UINT nWrittenFileHeaderSize = fwrite(&bmfh, 1, sizeof(BITMAPFILEHEADER), pFile);
UINT nWrittenInfoHeaderSize = fwrite(&BMIH, 1, sizeof(BITMAPINFOHEADER), pFile);
UINT nWrittenDIBDataSize = fwrite(myBits, 1, lImageSize, pFile);
fclose(pFile);
Now don't forget to free myBits when you are done that is alot of memory to bleed if you forget
In vino veritas
modified 11-Nov-16 0:33am.
|
|
|
|
|
Hi
I am getting ERROR_INVALID_HANDLE on GetLastError after WaitForSingleObject returns -1
I more or Less followed the MSDN example Using Mutex
My main thread does muthandle = CreateMutex(NULL,FALSE,NULL);
Second parameter is FALSE indicating it is not owned
Later a second Thread calls WaitForSingleObject(muthandle,INFINITE) and gets a -1 which
GetLastError retuns ERROR_INVALID_HANDLE
THANKS
|
|
|
|
|
what does CreateMutex return?
|
|
|
|
|
Well it's not NULL some low number like X'00000010' or X'00000030' now running x64 a handle is 64 bits I was looking at the RAX register
I tried the last parameter For CreateMutex NULL and with a string didn't matter the createmutex and WaitForSigleIbject are different threads
|
|
|
|