Basic command line question

Hello, I am relatively new to programming with C++ but I do have a good amount of experience programming with other languages. I've started working with some Open-Source software called voro++ and have run into a myriad of issues installing and running the software package on my computer but alas, I've finally gotten SOMETHING to run I just basically have no idea what I'm doing.

My question is regarding running C++ code from the command line. I have a file called import.cc that I am trying to modify but not getting anywhere with. I can run it from the command line using "run import" which is great, but when I go in to change some items with the code it doesn't seem to run any differently. To be clear, there are no errors when I type "run import" in the command line but when I try to modify some pieces of the code and re-run it, my modifications don't seem to have any effect.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  // File import example code
//
// Author   : Chris H. Rycroft (LBL / UC Berkeley)
// Email    : chr@alum.mit.edu
// Date     : August 30th 2011

#include "voro++.hh"
using namespace voro;

// Set up constants for the container geometry
const double x_min=-5,x_max=5;
const double y_min=-5,y_max=5;
const double z_min=0,z_max=10;

// Set up the number of blocks that the container is divided into
const int n_x=6,n_y=6,n_z=6;

int main() {

	// Create a container with the geometry given above, and make it
	// non-periodic in each of the three coordinates. Allocate space for
	// eight particles within each computational block
	container con(x_min,x_max,y_min,y_max,z_min,z_max,n_x,n_y,n_z,
			false,false,false,8);

	//Randomly add particles into the container
	con.import("pack_ten_cube1");

	// Save the Voronoi network of all the particles to text files
	// in gnuplot and POV-Ray formats
	con.draw_cells_gnuplot("pack_ten_cube1.gnu");
	con.draw_cells_pov("pack_ten_cube_v.pov");

	// Output the particles in POV-Ray format
	con.draw_particles_pov("pack_ten_cube_p.pov");
}
How are you compiling the C++ program after you modify the source code?

So I was confused on what "run import" did, I thought it compiled the program for me and everything but I think what the problem is is that although I'm modifying the code I am not recompiling it.

I tried compiling the code using Visual Studio Developer Command Prompt but got 8 Error LNK2019 errors. From what I can gather it means there's some functions that aren't defined or something.

Since I stumbled upon the open-source software I've had no idea what I'm doing, and there's no step by step tutorial on how to install and use the code, kind of frustrating for a noobie like me. The website says to use Cygwin for windows and GNU Make which are just two other pieces of software that I have no idea what they are used for.
Did you add all required libraries to your Visual Studio Developer Command Prompt?

Perhaps if you posted the complete error messages, exactly as they appear in your development environment someone may be able to tell you what you need to do to fix the problems.

The website says to use Cygwin for windows and GNU Make which are just two other pieces of software that I have no idea what they are used for.

Cygwin is a system to provide an environment similar to Linux. GNU Make is a program used to build complex programs in a Linux/Unix environment. While there are some open source projects that target Windows, most target the Linux environment.

closed account (48T7M4Gy)
Can this be due to the .cc and .hh file name extensions being used?
http://stackoverflow.com/questions/1545080/c-code-file-extension-cc-vs-cpp

Also this indicates a better solution http://lammps.sandia.gov/threads/msg52668.html
Last edited on
Can this be due to the .cc and .hh file name extensions being used?

Probably not. The errors are link errors not compile errors, which usually means that either some of the libraries were not added to the project, or you forgot to compile/link some other source file.

Thanks so much for your time jlb. And to be honest I don't know how to add libraries to a program or to make sure they are included when the program is compiled. What I did to try and solve that was just putting all the header and source files in the same folder. Here is the error message I get when trying to compile through the command prompt:


C:\cygwin64\voro++-0.4.6\examples\basic\import>cl /EHsc import.cc
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

import.cc
Microsoft (R) Incremental Linker Version 14.00.24213.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:import.exe
import.obj
import.obj : error LNK2019: unresolved external symbol "public: __thiscall voro::voronoicell_base::voronoicell_base(void)" (??0voronoicell_base@voro@@QAE@XZ) referenced in function "public: __thiscall voro::voronoicell::voronoicell(void)" (??0voronoicell@voro@@QAE@XZ)
import.obj : error LNK2019: unresolved external symbol "public: __thiscall voro::voronoicell_base::~voronoicell_base(void)" (??1voronoicell_base@voro@@QAE@XZ) referenced in function "public: __thiscall voro::voronoicell::~voronoicell(void)" (??1voronoicell@voro@@QAE@XZ)
import.obj : error LNK2019: unresolved external symbol "public: void __thiscall voro::voronoicell_base::draw_pov(double,double,double,struct _iobuf *)" (?draw_pov@voronoicell_base@voro@@QAEXNNNPAU_iobuf@@@Z) referenced in function "public: void __thiscall voro::container::draw_cells_pov<class voro::c_loop_all>(class voro::c_loop_all &,struct _iobuf *)" (??$draw_cells_pov@Vc_loop_all@voro@@@container@voro@@QAEXAAVc_loop_all@1@PAU_iobuf@@@Z)
import.obj : error LNK2019: unresolved external symbol "public: void __thiscall voro::voronoicell_base::draw_gnuplot(double,double,double,struct _iobuf *)" (?draw_gnuplot@voronoicell_base@voro@@QAEXNNNPAU_iobuf@@@Z) referenced in function "public: void __thiscall voro::container::draw_cells_gnuplot<class voro::c_loop_all>(class voro::c_loop_all &,struct _iobuf *)" (??$draw_cells_gnuplot@Vc_loop_all@voro@@@container@voro@@QAEXAAVc_loop_all@1@PAU_iobuf@@@Z)
import.obj : error LNK2019: unresolved external symbol "public: __thiscall voro::container_base::~container_base(void)" (??1container_base@voro@@QAE@XZ) referenced in function "public: __thiscall voro::container::~container(void)" (??1container@voro@@QAE@XZ)
import.obj : error LNK2019: unresolved external symbol "public: __thiscall voro::container::container(double,double,double,double,double,double,int,int,int,bool,bool,bool,int)" (??0container@voro@@QAE@NNNNNNHHH_N00H@Z) referenced in function _main
import.obj : error LNK2019: unresolved external symbol "public: void __thiscall voro::container::import(struct _iobuf *)" (?import@container@voro@@QAEXPAU_iobuf@@@Z) referenced in function "public: void __thiscall voro::container::import(char const *)" (?import@container@voro@@QAEXPBD@Z)
import.obj : error LNK2019: unresolved external symbol "public: bool __thiscall voro::voro_compute<class voro::container>::compute_cell<class voro::voronoicell>(class voro::voronoicell &,int,int,int,int,int)" (??$compute_cell@Vvoronoicell@voro@@@?$voro_compute@Vcontainer@voro@@@voro@@QAE_NAAVvoronoicell@1@HHHHH@Z) referenced in function "public: bool __thiscall voro::container::compute_cell<class voro::voronoicell,class voro::c_loop_all>(class voro::voronoicell &,class voro::c_loop_all &)" (??$compute_cell@Vvoronoicell@voro@@Vc_loop_all@2@@container@voro@@QAE_NAAVvoronoicell@1@AAVc_loop_all@1@@Z)
import.exe : fatal error LNK1120: 8 unresolved externals


Which is just WAY over my head, and I'm sorry if it looks so messy. I've tried creating a project in Visual Studio and adding all the header files and source code files and I get hundreds of errors that all look something like this:


1>voro++.obj : error LNK2005: "public: __thiscall voro::voronoicell_base::voronoicell_base(void)" (??0voronoicell_base@voro@@QAE@XZ) already defined in cell.obj
It seems that you should be trying to create a library not an executable.

On Windows without a terminal environment like Cygwin, it is possible to import and compile the library in many standard C++ development environments. Users have reported success in building the library with Microsoft Visual C++ Express and Code::Blocks.


You may want to try the code from this link, and follow the directions.
http://rodolphe-vaillant.fr/?e=55

Topic archived. No new replies allowed.