Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Controlling the order of options on the command line(Eclipse-CDT puts g++ command-line options out of order)
Controlling the order of options on the command line [message #785929] Sun, 29 January 2012 18:57 Go to next message
Sarah Rosen is currently offline Sarah RosenFriend
Messages: 2
Registered: January 2012
Junior Member
Ubuntu 11.10
g++ 4.6
Eclipse Platform Version: 3.7.0 Build id: I20110613-1736
Eclipse CDT 6.0.2.20102161416


Really simple OpenCV code:

//============================================================================
// Name        : cvHello.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <iomanip>
#include <iterator>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
using namespace cv;

int main(int argc, char* argv[]) {
	typedef std::istream_iterator<int> in;

	cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!

	IplImage* img =0;
	  int height,width,step,channels;
	  uchar *data;
	  int i,j,k;

	  if(argc<2){
	    std::cout << "Usage: main <image-file-name>" << endl;
	    exit(0);
	  }

	  // load an image
	  img = cvLoadImage(argv[1],4);

	  if(!img){
	    std::cout << "Could not load image file: "  << endl;
	    exit(0);
	  }

	  // get the image data
	  height    = img->height;
	  width     = img->width;
	  step      = img->widthStep;
	  channels  = img->nChannels;
	  data      = (uchar *)img->imageData;
	  std::cout << "Processing a "<< height << "x" << width << " image with " << channels << "channels. . .";
	  // create a window
	  cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
	  cvMoveWindow("mainWin", 100, 100);

	  // invert the image
	  for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
	    data[i*step+j*channels+k]=255-data[i*step+j*channels+k];

	  // show the image
	  cvShowImage("mainWin", img );

	  // wait for a key
	  cvWaitKey(0);

	  // release the image
	  cvReleaseImage(&img );
	return 0;
}



Console output on issuing Project ==> Build All:


**** Build of configuration Debug for project cvHello ****

make all 
Building file: ../src/cvHello.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/cvHello.d" -MT"src/cvHello.d" -o"src/cvHello.o" "../src/cvHello.cpp"
Finished building: ../src/cvHello.cpp
 
Building target: cvHello
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o"cvHello"  ./src/cvHello.o   -lopencv-core -lopencv-highgui
/usr/bin/ld: cannot find -lopencv-core
/usr/bin/ld: cannot find -lopencv-highgui
collect2: ld returned 1 exit status
make: *** [cvHello] Error 1



This line:

g++ -L/usr/local/lib -o"cvHello" ./src/cvHello.o -lopencv-core -lopencv-highgui

Fails.

If I rewrite it on the command-line, as such:

g++ -o"cvHello" ./src/cvHello.o -L/usr/local/lib -lopencv_core -lopencv_highgui

it succeeds and the code runs as expected. The only thing that changed was the placement of the -L{LIBRARY_SEARCH_PATH} arguement.

So the question becomes:

How do I control the order of the linker arguements?

Re: Controlling the order of options on the command line [message #785941 is a reply to message #785929] Sun, 29 January 2012 19:19 Go to previous messageGo to next message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
check the linker library setting, you could add libs and change the order:

http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_build_settings_tool.htm

Regards,
Klaus


Re: Controlling the order of options on the command line [message #785982 is a reply to message #785941] Sun, 29 January 2012 20:55 Go to previous message
Sarah Rosen is currently offline Sarah RosenFriend
Messages: 2
Registered: January 2012
Junior Member
I apologize for the disturbance. A careful examination of the original post reveals the problem.

-lopencv-core -lopencv-highgui <=== Wrong.
-lopencv_core -lopencv_highgui <=== Right.
Previous Topic:CDT + Gtkmm -> no autocomplete for gtkmm
Next Topic:Debugging shared libraries - finding sources
Goto Forum:
  


Current Time: Tue Apr 23 11:56:04 GMT 2024

Powered by FUDForum. Page generated in 0.04208 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top