How do I include a C++ library?

I have been trying to make a program using ncurses with c++ but I can’t figure out how to use it.I have it installed on my computer and I am new to Replit.com. Any help is appreciated.

1 Like

#include <yourlibrarynamehere>
Put that at the top of your file with iostream

You don’t need C++ on your computer to run it on Replit, we take care of that.

It still doesn’t work and I can’t run my library. Under the red scribbled line it says ‘ncurses.h’ file not found.
Here is my code if it helps.

#include <ncurses.h>
#include <iostream>

using namespace std;

int main() {
  std::cout << "Hello World!\n";
  return 0;
}
1 Like

By using headings at the top of your file.

#include <name> // libraries
#include “name.hpp” // hpp files
using namespace std; // standard library
1 Like

I believe it’s just curses.h

2 Likes

I have used the ncurses library in Vim before, so I don’t think it was my library name. And I have just used #include <ncurses.h> than programmed in the past.

2 Likes

Try taking away the n.

@fortnite2016 You could first try to upload ncurses to the Repl using the Upload File button next to the word File in the IDE. Then at the top of your C++ file, write #include "the file path" That should work

Sorry I could not reply the following day, but how do I get the file path?

@fortnite2016 For ncurses the file path could be NAME_OF_FILE where the name of your file would replace NAME_OF_FILE. If it’s in a folder then just add FOLDER_NAME/ to the begining of the path. If it doesn’t work then maybe include the link to your Repl so I can tell what the path would be with more certainty.

Here is my repel
https://replit.com/@fortnite2016/MindlessEuphoricStrategies
Thank you so much for helping me out.

@fortnite2016 The ncurses file is a Linux Zip file, so you’re not gonna be able to use it.
My recommendation is to fork this.

You need to install the package for the library. Click the vertical ellipsis by Files and then Show hidden files. Open your replit.nix file and add a depencency for ncurses. Add “pkgs.ncurses” below the other packages. That will get you the header and libs on your vm so your app will compile but not link. You still need to add -lncurses to the linker options. I’m not sure the right way to do it, but I just edited the makefile to add -lncurses before the -o when building main.
Satan only knows if this link will work, but I just made this repl. It’s why I registered on the site and how I found your question. https://replit.com/@TomHicks2/RudeTrustworthyAdvance
I think c++ is kindof a bastard child around here. It seems more like python and javascript are the first class citizens.

pkgs.ncurses.dev would be needed, I think.