Sublime Forum

C++14 no output displayed

#1

Getting this error. I’ve installed mingw gcc and all.

C:/TDM-GCC-64/bin/…/lib/gcc/x86_64-w64-mingw32/9.2.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: C:\Users\17dkd\AppData\Local\Temp\cccPwGZf.o:dkgeared.cpp:(.text+0x1c): undefined reference to std::istream::operator>>(int&)' C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\17dkd\AppData\Local\Temp\cccPwGZf.o:dkgeared.cpp:(.text+0x2d): undefined reference tostd::ostream::operator<<(int)’
C:/TDM-GCC-64/bin/…/lib/gcc/x86_64-w64-mingw32/9.2.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: C:\Users\17dkd\AppData\Local\Temp\cccPwGZf.o:dkgeared.cpp:(.text+0x4c): undefined reference to std::ios_base::Init::~Init()' C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\17dkd\AppData\Local\Temp\cccPwGZf.o:dkgeared.cpp:(.text+0x7c): undefined reference tostd::ios_base::Init::Init()’
C:/TDM-GCC-64/bin/…/lib/gcc/x86_64-w64-mingw32/9.2.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: C:\Users\17dkd\AppData\Local\Temp\cccPwGZf.o:dkgeared.cpp:(.rdata$.refptr._ZSt4cout[.refptr._ZSt4cout]+0x0): undefined reference to std::cout' C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\17dkd\AppData\Local\Temp\cccPwGZf.o:dkgeared.cpp:(.rdata$.refptr._ZSt3cin[.refptr._ZSt3cin]+0x0): undefined reference tostd::cin’
collect2.exe: error: ld returned 1 exit status
[Finished in 1.1s with exit code 1]
[cmd: [‘gcc’, ‘D:\CP Prep\CP Codes\Initial\dkgeared.cpp’, ‘-o’, ‘dkgeared.exe’]]
[dir: D:\CP Prep\CP Codes\Initial]
[path: C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Intel\Intel® Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\MATLAB\R2019b\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\sqlite3;C:\TDM-GCC-64\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Intel\Intel® Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\MATLAB\R2019b\bin;C:\Users\17dkd\AppData\Local\Microsoft\WindowsApps;C:\Python37\Scripts;C:\Users\17dkd\AppData\Local\Microsoft\WindowsApps;C:\TDM-GCC-64\bin;C:\TDM-GCC-64\include;]

0 Likes

#2

Based on the symbols that are missing, it looks like your issue is related to the C++ base libraries not being included in the link. The build is using gcc; I would suggest trying it with g++ and see if that works better.

0 Likes

#3

yes I’ve installed the mingw g++ gcc package already.

0 Likes

#4

when I compile it using C++ single build it just says “finished {1.4 sec}” and when compiled using C++14 it shows that message. In both cases output isn’t displayed in the txt file.

0 Likes

#5

even if I try printf() then also same error.

0 Likes

#6

What I meant by my comment above is that the build system you’re using is executing gcc (the C compiler) and not g++ (the C++ compiler). So, although it may be smart enough to know that the file it's compiling is a C++ file, I would not be entirely surprised ifgcc` assumed that it was compiling straight and didn’t include the C++ base libraries as a part of it’s internal link step.\

The C++ Single File build has two variants; one that just compiles the code, and one that compiles it and also tries to run it. If you see it say it’s done with no errors, that’s a good indication that you chose the main build, which only compiles (which worked).

In that case, I would suggest trying to select that build, but use Tools > Build With and select the Run variant, and see if that works better for you.

If it does, then you could use View Package File to open the C++ Single File.sublime-build file to see what it’s doing and use it as a template for your own. However most of what it’s doing is using g++ instead of gcc to compile the code.

0 Likes