|
Vaclav_Sal wrote: However, I cannot find in any pkg_config related sites HOW to actually tell GCC linker to use this "opencv.pc".
The linker doesn't use .pc files. You must use the pkg-config command to generate the options for the compiler or linker. Use command substitution[^] to embed the pkg-config command on the linker command line or to store the output in a variable.
|
|
|
|
|
Thanks for actually answering my question without an additional commentaries.
Appreciate that.
I have also found that I could include the pkg_config command(s) in "make" file.
Of course I need to figure out how to either modify the "make" automatically build by IDE or learn how to build my own.
Cheers
Vaclav
|
|
|
|
|
Still struggling with the issue
Here is exact syntax I have used - it suppose to "print" , I assume substitute, the libraries in package ( opencv ) to the linker as -l options.
It does not matter if the options are --libs opencv or opencv --libs - which is expected.
"$(pkg-config opencv --libs)"
Here is partial liker output
make all
Building target: TEST_1
Invoking: GCC C++ Linker
<b>g++: error: missing argument to ‘-l’</b>
g++ -L/usr/local/lib -o "TEST_1" ./src/TEST_1.o <b>-l""</b>
make: *** [TEST_1] Error 1
makefile:45: recipe for target 'TEST_1' failed
I have tried different format / syntax and "$(command)" is correct per the link you have provided. From the output it is notable that no -l files were included - -l"".
I do not know what else can be wrong. The command does not expands to anything linker can use and it should look as terminal output.
jim-desktop $ pkg-config opencv --libs
-L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_viz -lopencv_core
I have asked in several forums and all I am getting is how to add -L/-l options MANUALLY to the linker options.
BTW including ":" before the manually inserted file name specifies to the pkg-config to use library file WITHOUT using the file extension. Nice to know but does not solve my issue.
Cheers
Vaclav
|
|
|
|
|
Hi All,
In my MFC project, some Text box should appear in UI for 32 bit builds and that is not appear for 64 bit builds.
For this I have added the following piece of code in Resource.h file
Resource.h:
#ifndef _WIN64
#define INCLUDE_32_BUILDS 1
#endif
#ifdef INCLUDE_32_BUILDS
#define IDC_GS_CMB_TYPE 5176
#endif
and the code in the resource file is:
#ifdef INCLUDE_32_BUILDS
LTEXT "Receiver Output Protocol :",IDC_STATIC,16,42,123,8
EDITTEXT IDC_GS_EDIT_TYPE, 150, 42, 84, 85, ES_AUTOHSCROLL | ES_READONLY
#endif
I want to show above text box for only 32 bit application and not in 64 bit application
I am able to compile the code successfully, but still I am able to see the above text in UI for 64 bit application. I think #ifdef INCLUDE_32_BUILDS is not working properly in resource file.
Please let me know how to make sure that the #ifdef INCLUDE_32_BUILDS work and the text box should not appear for 64 bit application?
Thanks,
Lakshmi.
modified 17-Nov-16 23:35pm.
|
|
|
|
|
You need to ensure that your .rc file has access to that defined value. Either add it via a #include d header file, or in your project properties.
|
|
|
|
|
Expanding Richards answer the resource compiler does not have access to the standard C preprocessor predefined macros because you haven't included any of the standard headers
_WIN64 whilst a standard predefined macro in the C preprocessor is not predefined in the resource compiler. So your #ifdef _WIN64 is failing because _WIN64 doesn't exist to the resource compiler.
And trying to do so you usually need to use RC invoke to go around some stuff the header files contain:
RC with predefined Macros (Windows)[^]
So Resource compiler starts with exactly one macro RC_INVOKED and includes only macros that are included in it's include section. Once upon a time there was an undocumented _WIN32 but I think even that has gone these days.
So the more usual trick is to use the build options tab on the resource file to preset a define. On your resource build you have configurations and you can add predefined macros.
Config Properties -> Resources -> General In the macros tab add _WIN64 manually to the 64 bit build. Add _WIN32 to the 32 bit build tab.
In vino veritas
|
|
|
|
|
Thanks Leon. It worked.
Thanks,
Lakshmi
|
|
|
|
|
I hope this forum will forgive me to ask this, but...
CMake wants to have line added
<b><b><b></b></b>cmake_minimum_required(VERSION 3.5)</b>
after which opencv.sh complains
./opencv.sh: line 1: syntax error near unexpected token `VERSION'
./opencv.sh: line 1: `cmake_minimum_required(VERSION 3.5)'
I am enclosing my crude log to illustrate some details.
And no, I do not know how to change CMake options to remove this version requirement and still would like to know the "syntax" error I made.
pre lang="text"><pre lang="text">CMake Error at traincascade/CMakeLists.txt:2 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
<b><b><b></b></b>cmake_minimum_required(VERSION 3.5)</b>
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
Configuring incomplete, errors occurred!
after adding
CMake Error at traincascade/CMakeLists.txt:2 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.5)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
Configuring incomplete, errors occurred!
after adding
Cmake complains
im-desktop $ ./opencv.sh
./opencv.sh: line 1: syntax error near unexpected token `VERSION'
./opencv.sh: line 1: `cmake_minimum_required(VERSION 3.5)'
jim@jim-desktop $
</pre></pre>
Cheers
Vaclav
|
|
|
|
|
./opencv.sh: line 1: syntax error near unexpected token `VERSION'
./opencv.sh: line 1: `cmake_minimum_required(VERSION 3.5)'
The error ir pretty clear:
There is a syntax error in line 1 of the file opencv.sh. The .sh extension indicates that it is a shell script file which is processed by the shell (probably bash) which will off course know nothing about CMake commands.
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.5)
Here CMake complains about a missing command in the file CMakeLists.txt.
So you have to add the command to the CMake file CMakeLists.txt.
|
|
|
|
|
It is not about clarity of the error - I am asking WHAT is the syntax error.
I have "cut and paste" the required line from the CMake output.
Do I need to define "token" VERSION" ?
How?
|
|
|
|
|
You are missing the point it is complaining about there is no cmake_minimum_required(VERSION 3.5) in CMakeLists.txt
You said you cut and paste "cmake_minimum_required(VERSION 3.5)" but did you put it into CMakeLists.txt, you didn't put in the script file per chance??????
I am not being condescending here but I need to check, you do get the script file has nothing to do with cmake. Like you we are a bit perplexed because it's step 1 of any cmake file.
Usually the first two lines of CMakeLists.txt are
make_minimum_required (VERSION x.x)
project (_MY_PROJECT_NAME_)
_MY_PROJECT_NAME_ being what you want to call the project
I am sorry for having to ask and check all these really beginner stuff but there is something strange going on.
Whatever the situation I suggest you simply open up a command line window, change to the directory and manually type in the cmake command (so we have any scripts out of the way) and we can see the exact screen spit from cmake itself without the script which is just another source of possible error.
Assuming we pass all this basic stuff there is left one other possibility that your first makelist pulls other makelists and those later makelists have version requirements but that is not the sort of error you seem to be getting. The problem is the exact messages change depending on version CMake and exact OS type so I will leave it as a possibility.
In vino veritas
modified 17-Nov-16 0:42am.
|
|
|
|
|
The syntax error is:
The program processing the file is not able to parse the command cmake_minimum_required(VERSION 3.5) .
The reason is:
You have pasted the command into the file opencv.sh which is processed by the shell (the Unix command line interpreter; see Unix shell - Wikipedia[^] ).
But it should be pasted into the file CMakeLists.txt which is processed by CMake.
The solution (see my initial answer):
Quote: So you have to add the command to the CMake file CMakeLists.txt. instead of opencv.sh.
|
|
|
|
|
First use of CMake, went relatively OK
I did run CMake to build OpenCV , build it with "warning":
CMake Warning at CMakeLists.txt:1250 (message):
The source directory is the same as binary directory. "make clean" may
damage the source tree
What is "source directory" ?
I did messed up some of the "destinations" , but before I'll try it again like to have an answer about "source directory".
Thanks
Cheers Vaclav
<b>The "source directory" CMake asked for was directory WERE CMakeLists.txt file is.</b>
-- modified 18-Nov-16 10:33am.
|
|
|
|
|
Vaclav_Sal wrote: What is "source directory" ?
isn't that where the source files live?
|
|
|
|
|
Duh, WHOSE source ? CMake or the OpenCV ?
|
|
|
|
|
OpenCV.
it's complaining that cleaning the build products might damage the source because they're in the same directories.
|
|
|
|
|
Yes, I got "the complaint " OK that why I was not sure about the source directory.
Thanks
|
|
|
|
|
CMake expects you to run it "out of the source tree"... meaning that you run it from some "build" directory where all the build binaries will be stored. That keeps the source separate from any build artifacts. It's warning you that you're building from within your source directory.
In simple terms... if you have a source tree that looks like this:
OpenCV
|-directory1
|-directory2
|-directory3
|-source_file1
|-source_file2
|-CMakeLists.txt
When you run the CMake command, it should be from a separate, self contained directory:
OpenCV
|-build_dir
|-directory1
|-directory2
|-directory3
|-source_file1
|-source_file2
|-CMakeLists.txt
That keep all the build artifacts in "build_dir" so if you need to blow away your build, it's easy to do so without messing with the source. In this case, to launch cmake, go into your build_dir and launch with cmake ../ -DANYOTHERCMAKEARGS .
|
|
|
|
|
I think the problem is "descriptive terminology".
I have a "mother directory" OpenCV with CMakeList.txt file I execute using CMake.
I did not bother to find were CMake resides.
Now CMake wants to know "source directory".
That is why I asked - apparently it is the "mother directory" and not some specific real source code of OpenCV.
( I suppose analyzing CMake would give some clue )
Now CMake will build OpenCV library and again - where should this "build" be?
Logically it belongs under the mother directory just to keep things under common directory.
Apparently, and I do not discount I made some other mistake, that caused the warning.
It all sounds pretty simple, but turns difficult to troubleshoot when things do not go right.
For example CMake finishes the "build" gives no "option" to quit / exit -just ask for same "click this or that again ".
But I am making some progress thanks to this forum.
Cheers
Vaclav
|
|
|
|
|
I have no idea how my initial post got duplicated.
My apology to forum
Vaclav
|
|
|
|
|
Could I post a question about Eclipse ?
Have a problem linking to library ( GCC options -L -l) and for a week I got no response elsewhere.
Thanks for checking.
Cheers '
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: Could I post a question about Eclipse ?
Yes, you may.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
|
Sure but there isn't much to those two they are just followed by a folder path string for the library directory or the include directory.
For header files GCC uses 4 default directories in a set order, the name of those directories is set when the version of GCC.EXE was created. So I can't tell you what they are because it depends on versions, CPU etc. However you can get them back out to screen with a command
GCC -v
I don't do a lot with libraries and from what I know there are 2 default directories in a set order again set at compile time of the linker executable ld.exe and again it has a command to display them
ld -v
Your commands above change the user directories and you can check what is happening by inserting your command line and putting -v at end and you can see what it changes.
In vino veritas
modified 13-Nov-16 21:43pm.
|
|
|
|
|
Thanks Leon,
this is my first usage of Eclipse and I am in "GUI" stage so far.
The problem is little too much for me.
First I used install.sh script for OpenCV and added "library search path" (-L) /usr/local/lib.
Than I am suppose to choose the actual library to use via (-l) from pull down box - but there is no pull down , only text box.
After "updating " Eclipse to newest I noticed that when I type in search path /usr/local/lib it ends up as "/usr/local/lib" , but still no pull down box with the libraries. I must be missing some other option.
( I do wish I was better using command line, but I am not ready for it.)
So I added cv2.so under library add (-l) .
Now everything compiles , but linker stops because it cannot find the "cv2.so" - but I can see it in correct directory.
I still think my (-l) syntax is wrong.
I also tryied to link to OpenCV .../build/lib with same results . This "build/lib" was a product of CMake I found with OpenCV.
I think my biggest issue is - I do not understand how does "shared" library works in Elipse and which library search path is correct.
|
|
|
|
|
Have you checked at CDT Documentation[^]? The command line options for GCC will all be listed on the GCC website, but generally for linking you need the directories listed via -L (capital L), and the names of the libraries vie -l (small l). It is sometime since I have built an application on Unix/Linux so some features may have changed.
It would probably help if you showed your complete GCC command line (between <pre> tags for clarity.) and the exact error message(s) that you receive.
|
|
|
|