Skip to content

Commit d5561ba

Browse files
committed
Add example for test compilation with the library.
1 parent a903b3c commit d5561ba

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ New calculator class can thus be readily defined for any quantity that is
2222
obtained by iteration over atom pairs.
2323

2424
For more information see user manual at
25-
http://www.diffpy.org/doc/libdiffpy/.
25+
http://www.diffpy.org/doc/libdiffpy.
2626

2727

2828
## REQUIREMENTS
@@ -36,18 +36,19 @@ libdiffpy library requires C++ compiler and the following software:
3636
Recommended software:
3737

3838
* `libobjcryst` - C++ library of free objects for crystallography,
39-
https://github.com/diffpy/libobjcryst/
40-
* `cxxtest` - CxxTest Unit Testing Framework, http://cxxtest.com/
39+
https://github.com/diffpy/libobjcryst
40+
* `cxxtest` - CxxTest Unit Testing Framework, http://cxxtest.com
4141

42-
Required software is usually available in the system package manager,
43-
for example, on Ubuntu Linux the dependencies can be installed as:
42+
On Ubuntu Linux the required software can be installed using the
43+
system package manager:
4444

4545
```sh
4646
sudo apt-get install \
4747
build-essential scons libboost-dev libgsl0-dev
4848
```
4949

50-
For Mac OS X machine with the MacPorts package manager one could do
50+
For Mac OS X machine with the MacPorts package manager the installation
51+
command is
5152

5253
```sh
5354
sudo port install scons boost gsl
@@ -68,6 +69,19 @@ This installs libdiffpy for all users under the `/usr/local` directory.
6869
If administrator (root) access is not available, see the usage info from
6970
`scons --help` for options to install to a user-writable location.
7071

72+
To verify libdiffpy installation, compile and run the included
73+
test code [examples/testlib.cpp](examples/testlib.cpp)
74+
75+
```sh
76+
cd examples
77+
c++ testlib.cpp -ldiffpy
78+
./a.out
79+
```
80+
81+
If compilation fails because of missing header files or missing libdiffpy
82+
library, adjust the `CPATH` and `LIBRARY_PATH` environment variables or
83+
use the `-I` or `-L` compiler options. If the libdiffpy shared library
84+
cannot be found at runtime, adjust the `LD_LIBRARY_PATH` environment variable.
7185

7286
## DEVELOPMENT
7387

examples/testlib.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Test program for checking the installation of libdiffpy shared library.
2+
// Compile and run this code using:
3+
//
4+
// c++ testlib.cpp -ldiffpy
5+
// ./a.out
6+
7+
8+
#include <iostream>
9+
#include <diffpy/srreal/ScatteringFactorTable.hpp>
10+
11+
int main(int argc, char* argv[])
12+
{
13+
using namespace diffpy::srreal;
14+
ScatteringFactorTablePtr ntbl;
15+
ntbl = ScatteringFactorTable::createByType("neutron");
16+
ntbl->lookup("Pb");
17+
std::cout << "Installation of libdiffpy shared library works!\n";
18+
return 0;
19+
}

0 commit comments

Comments
 (0)