Paint pixels in c++

Asked

Viewed 81 times

0

Hello, I needed a function to paint pixels on the console.
I came up with a solution here but when compiling gives me the following mistake:

C: Users user user Appdata Local Temp ccORhjHu. o:test.cpp:(.text+0xa1): Undefined Reference to `Setpixel@16'
collect2.exe: error: Ld returned 1 Exit status

I would like to be provided with a way to correct this mistake or another way to do the same thing.

Note: I use windows 7 32-bit, with mingw c++ installed

  • 1

    You included the libgdi32.a in the compilation (with -lgdi32)?

  • I include this flag but gives another error. Gives this error: Undefined Reference to 'Std::ios_base::Init::Init()'

  • What is the complete command you are using to compile?

  • gcc filename.cpp -lgdi32 and includes unistd. h library and replaces cin.ignore(); for sleep(5); because I was making a mistake

  • Isn’t the program in C++? If it is, the line should be g++ filename....... The gcc is for C programs, not C++

  • Thank you very much! It worked, just one thing, gcc should work because cpp is C Plus Plus (C++). I could turn that comment into an answer to mark it as correct?

Show 1 more comment

1 answer

1


According to the comments, the error was corrected after including the GDI32 lib (libgdi32.a), where the function is located SetPixel.

The mistake:

undefined reference to 'std::ios_base::Init::Init()' 

occurred due to the use of the compiler gcc (used to compile programs in C).

The correct compiler for the C++ language in the package Mingw32 is the: g++.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.