0

I am still very inexperienced with cpp.

I have a function I'd like to call from a .cpp file, below is its header:

int wsq_encode(unsigned char* bufferRAW, int width, int height, char compressRate, std::ostream &streamWSQ); 

I need to write a code that opens tons of RAW image formats (bufferRAW) and compress them to .wsq according to this company's algorithm, all the while using the width, height and compression rate parameters via argv[]. The output file is supposed to go to streamWSQ.

The wsq_encode is closed and I won't go into it. I am having trouble passing the output file to wsq_encode. The code I need to write is very simple:

#include "../inc/libcorewsq.h" #include <fstream> #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> int main (int argc, char **argv) { unsigned char raw[20]; strcpy ((char*)raw, argv[1]); int width = atoi(argv[2]); int height = atoi(argv[3]); ostream arq; arq.open ("out.wsq"); wsq_encode (raw, width, height, 5, arq); return 0; } 

I still battling how to do this. I need to compile and run it using GCC 4.4.7 inside a CentOS ssh shell.

4
  • Explain your "trouble". Commented Jan 10, 2014 at 18:47
  • The function I need to call accepts a ostream parameter to write the output. If I try to qualify std::ostream or add "using namespace std;", the error message "undefined reference to `wsq_encode(unsigned char*, int, int, char, std::basic_ostream<char, std::char_traits<char> >&)'" ensues, even though there is a #include "../inc/libcorewsq.h". Commented Jan 10, 2014 at 19:32
  • #include is irrelevant. You failed to link in the definition of the function. Commented Jan 10, 2014 at 19:36
  • @LightnessRacesinOrbit that was it. Too bad I can't promote your comment to an answer Commented Jan 16, 2014 at 18:23

2 Answers 2

1

Try using std::ofstream, where the f is for files.

Opening std::ostream opens a generic output stream.

Sign up to request clarification or add additional context in comments.

Comments

0

#include is irrelevant: you failed to link in the definition of the function.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.