I'm learning ns-3 on a virtual machine with ubuntu linux 20.04 and ns-3.35. I wrote in c++.
The yans-wifi-helper.h is included in my file.
And I wrote a line as below.
YansWifiPhyHelper phy = YansWifiPhyHelper::Default();
But when compiling
root#kotoridsk233-vm:/home/kotoridsk233/ns3_install/ns-allinone-3.35/ns-3.35# ./waf
Waf: Entering directory /home/kotoridsk233/ns3_install/ns-allinone-3.35/ns-3.35/build'
[2968/3038] Compiling scratch/try.cc
../scratch/try.cc: In function ‘int main(int, char**)’:
../scratch/try.cc:30:46: error: ‘Default’ is not a member of ‘ns3::YansWifiPhyHelper’
30 | YansWifiPhyHelper phy = YansWifiPhyHelper::Default();
| ^~~~~~~
Waf: Leaving directory /home/kotoridsk233/ns3_install/ns-allinone-3.35/ns-3.35/build'
Build failed
-> task in 'try' failed with exit status 1 (run with -v to display more information)
However, I read the doc of ns3::YansWifiPhyHelper. Default is one of the static public member functions.
My whole code is as below.(not finish yet)
#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/ssid.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("trytodohomework");
int
main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
Time::SetResolution (Time::NS);
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
NodeContainer wifinodes;
wifinodes.Create (100);
YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default();
phy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
phy.SetChannel (channel.Create());
WifiHelper wifi;
wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
WifiMacHelper mac;
NetDeviceContainer WifiDevice;
Ssid ssid;
ssid = Ssid ("wifi-network");
phy.Set ("ChannelNumber", UintegerValue (36));
mac.SetType ("ns3::StaWifiMac",
"QosSupported", BooleanValue (true),
"Ssid", SsidValue (ssid));
WifiDevice = wifi.Install (phy, mac, wifinodes.Get (0));
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (100),
"DeltaY", DoubleValue (100),
"GridWidth", UintegerValue (1000),
"LayoutType", StringValue ("RowFirst"));
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install(wifinodes);
InternetStackHelper stack;
stack.Install (wifinodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer WifiInterface;
WifiInterface = address.Assign (WifiDevice);
uint16_t port = 9;
UdpEchoServerHelper wifiserver (port);
ApplicationContainer wifiserverApp = wifiserver.Install (wifinodes.Get (0));
wifiserverApp.Start (Seconds (1.0));
wifiserverApp.Stop (Seconds (100.0));
UdpEchoClientHelper echoClient (WifiInterface.GetAddress(1),9);
echoClient.SetAttribute ("DataRate", StringValue ("1000kb/s"));
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1048576));
ApplicationContainer clientApps = echoClient.Install (wifinodes.Get(99));
clientApps.Start (Seconds (1.0));
clientApps.Stop (Seconds (100.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
My project uses qt webengine. The release version works fine, but debug version crashes very quickly when I navigate tumblr.com. Error message shown as below. I want to know what's this message about, and how to fix it.
Versions:
Qt 5.9.4 - msvc2015-32bit
windows 10
Error output:
[16056:14736:0128/180851.894:WARNING:sqlite_channel_id_store.cc(262)] Server bound cert database is too new.
[16056:14736:0128/180851.894:WARNING:sqlite_channel_id_store.cc(262)] Server bound cert database is too new.
[16056:14736:0128/180851.894:FATAL:sqlite_channel_id_store.cc(203)] Check failed: false. Unable to open cert DB.
Backtrace:
GetHandleVerifier [0x112471F7+262887]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x1118256B+3003]
IsSandboxedProcess [0x12D7FBD5+9233173]
IsSandboxedProcess [0x1496E3C7+38521607]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x1091BA15+7234709]
IsSandboxedProcess [0x143ABE13+32482643]
IsSandboxedProcess [0x143AEE24+32494948]
QtWebEngineCore::ColorChooserController::reject [0x101A8DBE+48654]
GetHandleVerifier [0x112538F4+313828]
IsSandboxedProcess [0x131BF2E2+13687330]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x10242484+52996]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x1024259B+53275]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x10243EF4+59764]
QtWebEngineCore::ColorChooserController::reject [0x101A8DBE+48654]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111CD7C7+310807]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111CCC83+307923]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x11200659+519337]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111909EC+61500]
BaseThreadInitThunk [0x76678654+36]
RtlGetAppContainerNamedObjectPath [0x77834A77+311]
RtlGetAppContainerNamedObjectPath [0x77834A47+263]
[16056:14736:0128/180851.894:FATAL:sqlite_channel_id_store.cc(203)] Check failed: false. Unable to open cert DB.
Backtrace:
GetHandleVerifier [0x112471F7+262887]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x1118256B+3003]
IsSandboxedProcess [0x12D7FBD5+9233173]
IsSandboxedProcess [0x1496E3C7+38521607]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x1091BA15+7234709]
IsSandboxedProcess [0x143ABE13+32482643]
IsSandboxedProcess [0x143AEE24+32494948]
QtWebEngineCore::ColorChooserController::reject [0x101A8DBE+48654]
GetHandleVerifier [0x112538F4+313828]
IsSandboxedProcess [0x131BF2E2+13687330]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x10242484+52996]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x1024259B+53275]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x10243EF4+59764]
QtWebEngineCore::ColorChooserController::reject [0x101A8DBE+48654]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111CD7C7+310807]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111CCC83+307923]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x11200659+519337]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111909EC+61500]
BaseThreadInitThunk [0x76678654+36]
RtlGetAppContainerNamedObjectPath [0x77834A77+311]
RtlGetAppContainerNamedObjectPath [0x77834A47+263]
The program has unexpectedly finished.
The process was ended forcefully.
WebView initialize:
view_ = new WebView(widget_);
QWebEnginePage *page = new QWebEnginePage(view_);
view_->setPage(page);
page->settings()->setAttribute(QWebEngineSettings::AutoLoadImages, true);
page->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
page->settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, true);
page->settings()->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, true);
page->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
page->settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true);
page->settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::WebGLEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true);
page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, true);
cookie_ = new CookieJar(this); // for cookie sync
page->profile()->setPersistentStoragePath(gVar.getCachePath());
page->profile()->setCachePath(gVar.getCachePath());
page->profile()->setHttpCacheMaximumSize(100 * 1024 * 1024);
page->profile()->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
page->profile()->setHttpUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36");
page->profile()->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
connect(view_->page(), SIGNAL(loadFinished(bool)),
SLOT(pageLoadFinished()), Qt::QueuedConnection);
QUrl url = QUrl::fromUserInput(kMainPageUrl);
view_->setUrl(url);
WebView is a delegate class, and do nothing:
class WebView : public QWebEngineView
{
Q_OBJECT
public:
explicit WebView(QWidget *parent = 0);
};
run cmd.exe
cd %AppData%/../Local/qwebengine
rmdir /s QtWebEngine
In my project, I build Lua5.1 with library "lfs"(https://github.com/keplerproject/luafilesystem) by adding lfs.c and lfs.h in Makefile of Lua, it works well.
But after upgrading to lua5.3, it fails like this:
$ lua test.lua
lua: test.lua:1: module 'lfs' not found:
no field package.preload['lfs']
no file '/usr/local/share/lua/5.3/lfs.lua'
no file '/usr/local/share/lua/5.3/lfs/init.lua'
no file '/usr/local/lib/lua/5.3/lfs.lua'
no file '/usr/local/lib/lua/5.3/lfs/init.lua'
no file './lfs.lua'
no file './lfs/init.lua'
no file '/usr/local/lib/lua/5.3/lfs.so'
no file '/usr/local/lib/lua/5.3/loadall.so'
no file './lfs.so'
stack traceback:
[C]: in function 'require'
test.lua:1: in main chunk
[C]: in ?
test.lua:
local lfs = require"lfs"
function attrdir (path)
for file in lfs.dir(path) do
if file ~= "." and file ~= ".." then
local f = path..'/'..file
print ("\t "..f)
local attr = lfs.attributes (f)
assert (type(attr) == "table")
if attr.mode == "directory" then
attrdir (f)
else
for name, value in pairs(attr) do
print (name, value)
end
end
end
end
end
attrdir(".")
I've checked that the latest "lfs" library is Lua5.3 supported.
My OS is macos 10.12, and here is the makefile i'm using
# Makefile for building Lua
# See ../doc/readme.html for installation and customization instructions.
# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
# Your platform. See PLATS for possible values.
PLAT= none
CC= gcc -std=gnu99
CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)
LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
LIBS= -lm $(SYSLIBS) $(MYLIBS)
AR= ar rcu
RANLIB= ranlib
RM= rm -f
SYSCFLAGS=
SYSLDFLAGS=
SYSLIBS=
MYCFLAGS=
MYLDFLAGS=
MYLIBS=
MYOBJS=
# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
LUA_A= liblua.a
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
ltm.o lundump.o lvm.o lzio.o
LIB_O= lfs.o crc32.o lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o
BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
LUA_T= lua
LUA_O= lua.o
LUAC_T= luac
LUAC_O= luac.o
ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
ALL_A= $(LUA_A)
# Targets start here.
default: $(PLAT)
all: $(ALL_T)
o: $(ALL_O)
a: $(ALL_A)
$(LUA_A): $(BASE_O)
$(AR) $# $(BASE_O)
$(RANLIB) $#
$(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o $# $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $# $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
clean:
$(RM) $(ALL_T) $(ALL_O)
depend:
#$(CC) $(CFLAGS) -MM l*.c
echo:
#echo "PLAT= $(PLAT)"
#echo "CC= $(CC)"
#echo "CFLAGS= $(CFLAGS)"
#echo "LDFLAGS= $(SYSLDFLAGS)"
#echo "LIBS= $(LIBS)"
#echo "AR= $(AR)"
#echo "RANLIB= $(RANLIB)"
#echo "RM= $(RM)"
# Convenience targets for popular platforms
ALL= all
none:
#echo "Please do 'make PLATFORM' where PLATFORM is one of these:"
#echo " $(PLATS)"
aix:
$(MAKE) $(ALL) CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" SYSLDFLAGS="-brtl -bexpall"
bsd:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-Wl,-E"
c89:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_C89" CC="gcc -std=c89"
#echo ''
#echo '*** C89 does not guarantee 64-bit integers for Lua.'
#echo ''
freebsd:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -lreadline"
generic: $(ALL)
linux:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
macosx:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline" CC=cc
mingw:
$(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
$(MAKE) "LUAC_T=luac.exe" luac.exe
posix:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX"
solaris:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_REENTRANT" SYSLIBS="-ldl"
# list targets that do not create files (but not all makes understand .PHONY)
.PHONY: all $(PLATS) default o a clean depend echo none
# DO NOT DELETE
lapi.o: lapi.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lstring.h \
ltable.h lundump.h lvm.h
lauxlib.o: lauxlib.c lprefix.h lua.h luaconf.h lauxlib.h
lbaselib.o: lbaselib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lbitlib.o: lbitlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lcode.o: lcode.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \
llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \
ldo.h lgc.h lstring.h ltable.h lvm.h
lcorolib.o: lcorolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lctype.o: lctype.c lprefix.h lctype.h lua.h luaconf.h llimits.h
ldblib.o: ldblib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
ldebug.o: ldebug.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
lobject.h ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h \
ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lvm.h
ldo.o: ldo.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lopcodes.h \
lparser.h lstring.h ltable.h lundump.h lvm.h
ldump.o: ldump.c lprefix.h lua.h luaconf.h lobject.h llimits.h lstate.h \
ltm.h lzio.h lmem.h lundump.h
lfunc.o: lfunc.c lprefix.h lua.h luaconf.h lfunc.h lobject.h llimits.h \
lgc.h lstate.h ltm.h lzio.h lmem.h
lgc.o: lgc.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h
linit.o: linit.c lprefix.h lua.h luaconf.h lualib.h lauxlib.h
liolib.o: liolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
llex.o: llex.c lprefix.h lua.h luaconf.h lctype.h llimits.h ldebug.h \
lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lgc.h llex.h lparser.h \
lstring.h ltable.h
lmathlib.o: lmathlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lmem.o: lmem.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h
loadlib.o: loadlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lobject.o: lobject.c lprefix.h lua.h luaconf.h lctype.h llimits.h \
ldebug.h lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h \
lvm.h
lopcodes.o: lopcodes.c lprefix.h lopcodes.h llimits.h lua.h luaconf.h
loslib.o: loslib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lparser.o: lparser.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \
llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \
ldo.h lfunc.h lstring.h lgc.h ltable.h
lstate.o: lstate.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h llex.h \
lstring.h ltable.h
lstring.o: lstring.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \
lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h
lstrlib.o: lstrlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
ltable.o: ltable.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h
ltablib.o: ltablib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
ltm.o: ltm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h ltable.h lvm.h
lua.o: lua.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
luac.o: luac.c lprefix.h lua.h luaconf.h lauxlib.h lobject.h llimits.h \
lstate.h ltm.h lzio.h lmem.h lundump.h ldebug.h lopcodes.h
lundump.o: lundump.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \
lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h \
lundump.h
lutf8lib.o: lutf8lib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lvm.o: lvm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h \
ltable.h lvm.h
lzio.o: lzio.c lprefix.h lua.h luaconf.h llimits.h lmem.h lstate.h \
lobject.h ltm.h lzio.h
lfs.o: lfs.c lfs.h
crc32.o: crc32.c crc32.h
# (end of Makefile)
Any advice would be appreciated
This is what I have done and it works well:
linit.c
Added LFS in this section:
static const luaL_Reg loadedlibs[] = {
{"_G", luaopen_base},
...
{LUA_LFSLIBNAME, luaopen_lfs},
and in lualib.h added
#define LUA_LFSLIBNAME "lfs"
LUAMOD_API int (luaopen_lfs) (lua_State *L);
Then build as usual. Hope this helps.
You need add lfs to linit.c and rebuild.
I have to build a topology where 2 nodes are connected via the wifi network or cellular network.
In ns-3 I can't find examples to do so.
How could I build the topology ?
NS3 has only 4G network modules, WiMax and LTE. NS3 has no 2G or 3G modules.
Here is the example to create topology of a source node sending UDP packet to a sink node with combination of cellular network and Wifi Network.
LTE Network + Wifi Network
#include "ns3/lte-helper.h"
#include "ns3/epc-helper.h"
#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/wifi-module.h"
#include "ns3/csma-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wimax-module.h"
#include "ns3/internet-module.h"
#include "ns3/global-route-manager.h"
#include "ns3/ipcs-classifier-record.h"
#include "ns3/service-flow.h"
#include <iostream>
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/mobility-module.h"
#include "ns3/lte-module.h"
#include "ns3/point-to-point-helper.h"
#include <iomanip>
#include <string>
#include <fstream>
#include <vector>
NS_LOG_COMPONENT_DEFINE ("WimaxSimpleExample");
using namespace ns3;
int main (int argc, char *argv[])
{
Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
bool verbose = false;
int duration = 500, schedType = 0;
uint16_t numberOfUEs=2; //Default number of ues attached to each eNodeB
Ptr<LteHelper> lteHelper; //Define LTE
Ptr<EpcHelper> epcHelper; //Define EPC
NodeContainer remoteHostContainer; //Define the Remote Host
NetDeviceContainer internetDevices; //Define the Network Devices in the Connection between EPC and the remote host
Ptr<Node> pgw; //Define the Packet Data Network Gateway(P-GW)
Ptr<Node> remoteHost; //Define the node of remote Host
InternetStackHelper internet; //Define the internet stack
PointToPointHelper p2ph; //Define Connection between EPC and the Remote Host
Ipv4AddressHelper ipv4h; //Ipv4 address helper
Ipv4StaticRoutingHelper ipv4RoutingHelper; //Ipv4 static routing helper
Ptr<Ipv4StaticRouting> remoteHostStaticRouting;
Ipv4InterfaceContainer internetIpIfaces; //Ipv4 interfaces
CommandLine cmd;
cmd.AddValue ("scheduler", "type of scheduler to use with the network devices", schedType);
cmd.AddValue ("duration", "duration of the simulation in seconds", duration);
cmd.AddValue ("verbose", "turn on all WimaxNetDevice log components", verbose);
cmd.Parse (argc, argv);
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
//LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
//LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
NodeContainer ssNodes;
NodeContainer bsNodes;
ssNodes.Create (2);
bsNodes.Create (1);
uint32_t nCsma = 3;
NodeContainer p2pNodes;
p2pNodes.Create (2);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);
NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);
NodeContainer wifiApNode = p2pNodes.Get (0);
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
phy.SetChannel (channel.Create ());
WifiHelper wifi = WifiHelper::Default ();
wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
Ssid ssid = Ssid ("ns-3-ssid");
mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, ssNodes);
mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid));
NetDeviceContainer apDevices;
apDevices = wifi.Install (phy, mac, wifiApNode);
MobilityHelper mobility1;
mobility1.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (5.0),
"DeltaY", DoubleValue (10.0),
"GridWidth", UintegerValue (3),
"LayoutType", StringValue ("RowFirst"));
mobility1.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility1.Install (wifiApNode);
(wifiApNode.Get(0) -> GetObject<ConstantPositionMobilityModel>()) -> SetPosition(Vector(100.0, 501.0, 0.0));
InternetStackHelper stack1;
stack1.Install (csmaNodes);
stack1.Install (wifiApNode);
stack1.Install (ssNodes);
Ipv4AddressHelper address1;
address1.SetBase ("11.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address1.Assign (p2pDevices);
address1.SetBase ("11.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address1.Assign (csmaDevices);
address1.SetBase ("11.1.3.0", "255.255.255.0");
address1.Assign (staDevices);
address1.Assign (apDevices);
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps1 = echoServer.Install (csmaNodes.Get (nCsma));
serverApps1.Start (Seconds (1.0));
serverApps1.Stop (Seconds (duration+0.1));
UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1000));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps1 =
echoClient.Install (ssNodes.Get (0));
clientApps1.Start (Seconds (2.0));
clientApps1.Stop (Seconds (duration+0.1));
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
//pointToPoint.EnablePcapAll ("third");
phy.EnablePcap ("third", apDevices.Get (0));
//csma.EnablePcap ("third", csmaDevices.Get (0), true);
lteHelper = CreateObject<LteHelper> ();
epcHelper = CreateObject<EpcHelper> ();
lteHelper->SetEpcHelper (epcHelper);
lteHelper->SetSchedulerType("ns3::RrFfMacScheduler");
lteHelper->SetAttribute ("PathlossModel",
StringValue ("ns3::FriisPropagationLossModel"));
pgw = epcHelper->GetPgwNode ();
remoteHostContainer.Create (1);
remoteHost = remoteHostContainer.Get (0);
internet.Install (remoteHostContainer);
p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
internetDevices = p2ph.Install (pgw, remoteHost);
ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
internetIpIfaces = ipv4h.Assign (internetDevices);
remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
std::cout << "2. Installing LTE+EPC+remotehost. Done!" << std::endl;
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc;
positionAlloc = CreateObject<ListPositionAllocator> ();
positionAlloc->Add (Vector (0.0, 500.0, 0.0)); //STA
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
mobility.Install(ssNodes.Get(0));
Ptr<ConstantVelocityMobilityModel> cvm = ssNodes.Get(0)->GetObject<ConstantVelocityMobilityModel>();
cvm->SetVelocity(Vector (5, 0, 0)); //move to left to right 10.0m/s
positionAlloc = CreateObject<ListPositionAllocator> ();
positionAlloc->Add (Vector (0.0, 500.0, 10.0)); //MAG1AP
positionAlloc->Add (Vector (0.0, 510.0, 0.0)); //MAG2AP
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (NodeContainer(bsNodes.Get(0),ssNodes.Get(1)));
NetDeviceContainer ssDevs, bsDevs;
bsDevs = lteHelper->InstallEnbDevice (bsNodes);
ssDevs=lteHelper->InstallUeDevice (ssNodes);
for (uint16_t j=0; j < numberOfUEs; j++)
{
lteHelper->Attach (ssDevs.Get(j), bsDevs.Get(0));
}
Ipv4InterfaceContainer iueIpIface;
iueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ssDevs));
lteHelper->ActivateEpsBearer (ssDevs, EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT), EpcTft::Default ());
UdpServerHelper udpServer;
ApplicationContainer serverApps;
UdpClientHelper udpClient;
ApplicationContainer clientApps;
udpServer = UdpServerHelper (100);
serverApps = udpServer.Install (ssNodes.Get (0));
serverApps.Start (Seconds (6));
serverApps.Stop (Seconds (duration));
udpClient = UdpClientHelper (iueIpIface.GetAddress (0), 100);
udpClient.SetAttribute ("MaxPackets", UintegerValue (200000));
udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.004)));
udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
clientApps = udpClient.Install (remoteHost);
clientApps.Start (Seconds (6));
clientApps.Stop (Seconds (duration));
lteHelper->EnableTraces ();
NS_LOG_INFO ("Starting simulation.....");
Simulator::Stop(Seconds(duration));
Simulator::Run ();
Simulator::Destroy ();
NS_LOG_INFO ("Done.");
return 0;
}
WiMax Network + Wifi Network
#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/wifi-module.h"
#include "ns3/csma-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wimax-module.h"
#include "ns3/internet-module.h"
#include "ns3/global-route-manager.h"
#include "ns3/ipcs-classifier-record.h"
#include "ns3/service-flow.h"
#include <iostream>
NS_LOG_COMPONENT_DEFINE ("WimaxSimpleExample");
using namespace ns3;
int main (int argc, char *argv[])
{
bool verbose = false;
int duration = 1000, schedType = 0;
WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
CommandLine cmd;
cmd.AddValue ("scheduler", "type of scheduler to use with the network devices", schedType);
cmd.AddValue ("duration", "duration of the simulation in seconds", duration);
cmd.AddValue ("verbose", "turn on all WimaxNetDevice log components", verbose);
cmd.Parse (argc, argv);
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
//LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
//LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
switch (schedType)
{
case 0:
scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
break;
case 1:
scheduler = WimaxHelper::SCHED_TYPE_MBQOS;
break;
case 2:
scheduler = WimaxHelper::SCHED_TYPE_RTPS;
break;
default:
scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
}
NodeContainer ssNodes;
NodeContainer bsNodes;
ssNodes.Create (2);
bsNodes.Create (1);
uint32_t nCsma = 3;
NodeContainer p2pNodes;
p2pNodes.Create (2);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);
NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);
NodeContainer wifiApNode = p2pNodes.Get (0);
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
phy.SetChannel (channel.Create ());
WifiHelper wifi = WifiHelper::Default ();
wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
Ssid ssid = Ssid ("ns-3-ssid");
mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, ssNodes);
mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid));
NetDeviceContainer apDevices;
apDevices = wifi.Install (phy, mac, wifiApNode);
MobilityHelper mobility1;
mobility1.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (5.0),
"DeltaY", DoubleValue (10.0),
"GridWidth", UintegerValue (3),
"LayoutType", StringValue ("RowFirst"));
mobility1.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility1.Install (wifiApNode);
(wifiApNode.Get(0) -> GetObject<ConstantPositionMobilityModel>()) -> SetPosition(Vector(800.0, 0.0, 0.0));
InternetStackHelper stack1;
stack1.Install (csmaNodes);
stack1.Install (wifiApNode);
stack1.Install (ssNodes);
Ipv4AddressHelper address1;
address1.SetBase ("11.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address1.Assign (p2pDevices);
address1.SetBase ("11.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address1.Assign (csmaDevices);
address1.SetBase ("11.1.3.0", "255.255.255.0");
address1.Assign (staDevices);
address1.Assign (apDevices);
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps1 = echoServer.Install (csmaNodes.Get (nCsma));
serverApps1.Start (Seconds (1.0));
serverApps1.Stop (Seconds (duration));
UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1000));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps1 =
echoClient.Install (ssNodes.Get (0));
clientApps1.Start (Seconds (2.0));
clientApps1.Stop (Seconds (duration));
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
//pointToPoint.EnablePcapAll ("third");
phy.EnablePcap ("third", apDevices.Get (0));
//csma.EnablePcap ("third", csmaDevices.Get (0), true);
WimaxHelper wimax;
NetDeviceContainer ssDevs, bsDevs;
ssDevs = wimax.Install (ssNodes,
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
scheduler);
bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
wimax.EnableAscii ("bs-devices", bsDevs);
wimax.EnableAscii ("ss-devices", ssDevs);
Ptr<SubscriberStationNetDevice> ss[2];
for (int i = 0; i < 2; i++)
{
ss[i] = ssDevs.Get (i)->GetObject<SubscriberStationNetDevice> ();
ss[i]->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
}
Ptr<BaseStationNetDevice> bs;
bs = bsDevs.Get (0)->GetObject<BaseStationNetDevice> ();
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc;
positionAlloc = CreateObject<ListPositionAllocator> ();
positionAlloc->Add (Vector (-1061.0, 70.0, 0.0)); //STA
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
mobility.Install(ssNodes.Get(0));
Ptr<ConstantVelocityMobilityModel> cvm = ssNodes.Get(0)->GetObject<ConstantVelocityMobilityModel>();
cvm->SetVelocity(Vector (5, 0, 0)); //move to left to right 10.0m/s
positionAlloc = CreateObject<ListPositionAllocator> ();
positionAlloc->Add (Vector (-0.0, 40.0, 0.0)); //MAG1AP
positionAlloc->Add (Vector (0.0, 40.0, 0.0)); //MAG2AP
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (NodeContainer(bsNodes.Get(0),ssNodes.Get(1)));
InternetStackHelper stack;
stack.Install (bsNodes);
//stack.Install (ssNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
if (verbose)
{
wimax.EnableLogComponents (); // Turn on all wimax logging
}
/*------------------------------*/
UdpServerHelper udpServer;
ApplicationContainer serverApps;
UdpClientHelper udpClient;
ApplicationContainer clientApps;
udpServer = UdpServerHelper (100);
serverApps = udpServer.Install (ssNodes.Get (0));
serverApps.Start (Seconds (6));
serverApps.Stop (Seconds (duration));
udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.5)));
udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
clientApps = udpClient.Install (ssNodes.Get (1));
clientApps.Start (Seconds (6));
clientApps.Stop (Seconds (duration));
Simulator::Stop (Seconds (duration + 0.1));
wimax.EnablePcap ("wimax-simple-ss0", ssNodes.Get (0)->GetId (), ss[0]->GetIfIndex ());
wimax.EnablePcap ("wimax-simple-ss1", ssNodes.Get (1)->GetId (), ss[1]->GetIfIndex ());
wimax.EnablePcap ("wimax-simple-bs0", bsNodes.Get (0)->GetId (), bs->GetIfIndex ());
IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
Ipv4Mask ("0.0.0.0"),
SSinterfaces.GetAddress (0),
Ipv4Mask ("255.255.255.255"),
0,
65000,
100,
100,
17,
1);
ServiceFlow DlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN,
ServiceFlow::SF_TYPE_RTPS,
DlClassifierUgs);
IpcsClassifierRecord UlClassifierUgs (SSinterfaces.GetAddress (1),
Ipv4Mask ("255.255.255.255"),
Ipv4Address ("0.0.0.0"),
Ipv4Mask ("0.0.0.0"),
0,
65000,
100,
100,
17,
1);
ServiceFlow UlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_UP,
ServiceFlow::SF_TYPE_RTPS,
UlClassifierUgs);
ss[0]->AddServiceFlow (DlServiceFlowUgs);
ss[1]->AddServiceFlow (UlServiceFlowUgs);
NS_LOG_INFO ("Starting simulation.....");
Simulator::Run ();
ss[0] = 0;
ss[1] = 0;
bs = 0;
Simulator::Destroy ();
NS_LOG_INFO ("Done.");
return 0;
}
The codes is belong to these Author under GPL2 :
https://code.google.com/p/tesis-ns3/source/browse/trunk/lena/scratch/?r=5
The following crashes in CreateGlobalStringPtr:
#include "llvm/Support/DataTypes.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/Support/IRBuilder.h"
#include <vector>
#include <cstdio>
#include <string>
int main()
{
llvm::LLVMContext & context = llvm::getGlobalContext();
llvm::Module *module = new llvm::Module("asdf", context);
llvm::IRBuilder<> builder(context);
llvm::Value *helloWorld = builder.CreateGlobalStringPtr("hello world!\n"); // crash here
}
And this one doesn't, any idea what's happening here:
#include "llvm/Support/DataTypes.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/Support/IRBuilder.h"
#include <vector>
#include <cstdio>
#include <string>
int main()
{
llvm::LLVMContext & context = llvm::getGlobalContext();
llvm::Module *module = new llvm::Module("asdf", context);
llvm::IRBuilder<> builder(context);
// Added extra
llvm::FunctionType *funcType = llvm::FunctionType::get(builder.getVoidTy(), false);
llvm::Function *mainFunc = llvm::Function::Create(funcType, llvm::Function::ExternalLinkage, "main", module);
llvm::BasicBlock *entry = llvm::BasicBlock::Create(context, "entry", mainFunc);
builder.SetInsertPoint(entry);
llvm::Value *helloWorld = builder.CreateGlobalStringPtr("hello world!\n");
}
Not sure how creating a main routine and an entry point can remove the crash. Thought they were unrelated. Here are my options to g++ for compiling:
llvm-config --cxxflags --ldflags --libs
-I/usr/include -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -fno-exceptions -fno-rtti -fno-common -Woverloaded-virtual -Wcast-qual
-L/usr/lib -lpthread -lm
-lLLVMXCoreCodeGen -lLLVMTableGen -lLLVMSystemZCodeGen -lLLVMSparcCodeGen -lLLVMPTXCodeGen -lLLVMPowerPCCodeGen -lLLVMMSP430CodeGen -lLLVMMipsCodeGen -lLLVMMCJIT -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCDisassembler -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMPTXDesc -lLLVMPTXInfo -lLLVMPTXAsmPrinter -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMMBlazeDisassembler -lLLVMMBlazeAsmParser -lLLVMMBlazeCodeGen -lLLVMMBlazeDesc -lLLVMMBlazeAsmPrinter -lLLVMMBlazeInfo -lLLVMLinker -lLLVMipo -lLLVMInterpreter -lLLVMInstrumentation -lLLVMJIT -lLLVMExecutionEngine -lLLVMDebugInfo -lLLVMCppBackend -lLLVMCppBackendInfo -lLLVMCellSPUCodeGen -lLLVMCellSPUDesc -lLLVMCellSPUInfo -lLLVMCBackend -lLLVMCBackendInfo -lLLVMBlackfinCodeGen -lLLVMBlackfinDesc -lLLVMBlackfinInfo -lLLVMBitWriter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMX86Info -lLLVMAsmParser -lLLVMARMDisassembler -lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMDesc -lLLVMARMAsmPrinter -lLLVMARMInfo -lLLVMArchive -lLLVMBitReader -lLLVMAlphaCodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMAlphaDesc -lLLVMAlphaInfo -lLLVMMC -lLLVMSupport
CreateGlobalStringPtr is creating a GEP to your string, which the builder requires a function and basic block to Insert the instruction into.
See include/llvm/Support/IRBuilder.h