I am implementing RTP protocol in NS-2.35. on the platform Ubuntu 12.04. I have made some changes in the existing modules as per required. now I am configuring the changes and run make in the terminal. but getting the following error.
The error is at this step
<all the g++ call that cause the error>
And the error :
common/session-rtp.o: In function hdr_rtp_v2::access(Packet const*)':
session-rtp.cc:(.text._ZN10hdr_rtp_v26accessEPK6Packet[hdr_rtp_v2::access(Packet const*)] +0x7): undefined reference to `hdr_rtp_v2::offset_'
common/session-rtp.o: In function `hdr_rtcp_v2::access(Packet const*)':
session-rtp.cc:(.text._ZN11hdr_rtcp_v26accessEPK6Packet[hdr_rtcp_v2::access(Packet const*)] +0x7): undefined reference to `hdr_rtcp_v2::offset_'
collect2: ld returned 1 exit status
code:
#ifndef lint
static const char rcsid[] =
"#(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/apps/rtp.cc,v 1.26 2000/08/18 18:34:01 haoboy Exp $";
#endif
#include <stdlib.h>
#include "agent.h"
#include "config.h"
#include "rtp.h"
#include "random.h"
#include <string.h>
#include "rtp_v2.h"
#include "address.h"
#include "udp.h"
#include "ip.h"
#include <cstdlib>
#include <iostream.h>
#include <time.h>
int hdr_rtp_v2::offset_;
// RTP RFC 3550 Compliant Header Class
static class RTP_v2HeaderClass : public PacketHeaderClass {
public:
RTP_v2HeaderClass() : PacketHeaderClass("PacketHeader/RTP_v2", sizeof(hdr_rtp_v2)) {
bind_offset(&hdr_rtp_v2::offset_);
}
} class_rtp_v2_hdr;
// [...]
:
#include <stdlib.h>
#include "agent.h"
#include "config.h"
#include "rtp.h"
#include "random.h"
#include <string.h>
#include "rtcp_v2.h"
#include "address.h"
#include "udp.h"
#include "rtp_v2.h"
#define Receiver_Report 201
#define Sender_Report 200
#define seqno_initial_ 0
class RTCP_v2Agent;
int hdr_rtcp_v2::offset_;
// [...]
g++ -Wl,-export-dynamic -o ns tcp/linux/tcp_naivereno.o tcp/linux/src/tcp_cong.o tcp/linux/src/tcp_highspeed.o tcp/linux/src/tcp_bic.o tcp/linux/src/tcp_htcp.o tcp/linux/src/tcp_scalable.o tcp/linux/src/tcp_cubic.o tcp/linux/src/tcp_westwood.o tcp/linux/src/tcp_vegas.o tcp/linux/src/tcp_hybla.o tcp/linux/src/tcp_illinois.o tcp/linux/src/tcp_yeah.o tcp/linux/src/tcp_veno.o tcp/linux/src/tcp_compound.o tcp/linux/src/tcp_lp.o tcp/linux/ns-linux-c.o tcp/linux/ns-linux-param.o tools/random.o tools/rng.o tools/ranvar.o common/misc.o common/timer-handler.o common/scheduler.o common/object.o common/packet.o common/ip.o routing/route.o common/connector.o common/ttl.o trace/trace.o trace/trace-ip.o classifier/classifier.o classifier/classifier-addr.o classifier/classifier-hash.o classifier/classifier-virtual.o classifier/classifier-mcast.o classifier/classifier-bst.o classifier/classifier-mpath.o mcast/replicator.o classifier/classifier-mac.o classifier/classifier-qs.o classifier/classifier-port.o src_rtg/classifier-sr.o src_rtg/sragent.o src_rtg/hdr_src.o adc/ump.o qs/qsagent.o qs/hdr_qs.o apps/app.o apps/telnet.o tcp/tcplib-telnet.o tools/trafgen.o trace/traffictrace.o tools/pareto.o tools/expoo.o tools/cbr_traffic.o adc/tbf.o adc/resv.o adc/sa.o tcp/saack.o tools/measuremod.o adc/estimator.o adc/adc.o adc/ms-adc.o adc/timewindow-est.o adc/acto-adc.o adc/pointsample-est.o adc/salink.o adc/actp-adc.o adc/hb-adc.o adc/expavg-est.o adc/param-adc.o adc/null-estimator.o adc/adaptive-receiver.o apps/vatrcvr.o adc/consrcvr.o common/agent.o common/message.o apps/udp.o common/session-rtp.o apps/rtp.o tcp/rtcp.o common/ivs.o common/messpass.o common/tp.o common/tpm.o apps/worm.o tcp/tcp.o tcp/tcp-sink.o tcp/tcp-reno.o tcp/tcp-newreno.o tcp/tcp-vegas.o tcp/tcp-rbp.o tcp/tcp-full.o tcp/rq.o baytcp/tcp-full-bay.o baytcp/ftpc.o baytcp/ftps.o tcp/scoreboard.o tcp/scoreboard-rq.o tcp/tcp-sack1.o tcp/tcp-fack.o tcp/scoreboard1.o tcp/tcp-linux.o tcp/linux/ns-linux-util.o tcp/tcp-asym.o tcp/tcp-asym-sink.o tcp/tcp-fs.o tcp/tcp-asym-fs.o tcp/tcp-int.o tcp/chost.o tcp/tcp-session.o tcp/nilist.o sctp/sctp.o apps/sctp_app1.o sctp/sctp-timestamp.o sctp/sctp-hbAfterRto.o sctp/sctp-multipleFastRtx.o sctp/sctp-mfrHbAfterRto.o sctp/sctp-mfrTimestamp.o sctp/sctp-cmt.o sctp/sctpDebug.o dccp/dccp_sb.o dccp/dccp_opt.o dccp/dccp_ackv.o dccp/dccp_packets.o dccp/dccp.o dccp/dccp_tcplike.o dccp/dccp_tfrc.o tools/integrator.o tools/queue-monitor.o tools/flowmon.o tools/loss-monitor.o queue/queue.o queue/drop-tail.o adc/simple-intserv-sched.o queue/red.o queue/semantic-packetqueue.o queue/semantic-red.o tcp/ack-recons.o queue/sfq.o queue/fq.o queue/drr.o queue/srr.o queue/cbq.o queue/jobs.o queue/marker.o queue/demarker.o link/hackloss.o queue/errmodel.o queue/fec.o link/delay.o tcp/snoop.o gaf/gaf.o link/dynalink.o routing/rtProtoDV.o common/net-interface.o mcast/ctrMcast.o mcast/mcast_ctrl.o mcast/srm.o common/sessionhelper.o queue/delaymodel.o mcast/srm-ssm.o mcast/srm-topo.o routing/alloc-address.o routing/address.o lib/int.Vec.o lib/int.RVec.o lib/dmalloc_support.o webcache/http.o webcache/tcp-simple.o webcache/pagepool.o webcache/inval-agent.o webcache/tcpapp.o webcache/http-aux.o webcache/mcache.o webcache/webtraf.o webcache/webserver.o webcache/logweb.o empweb/empweb.o empweb/empftp.o realaudio/realaudio.o mac/lanRouter.o classifier/filter.o common/pkt-counter.o common/Decapsulator.o common/Encapsulator.o common/encap.o mac/channel.o mac/mac.o mac/ll.o mac/mac-802_11.o mac/mac-802_11Ext.o mac/mac-802_3.o mac/mac-tdma.o mac/smac.o mobile/mip.o mobile/mip-reg.o mobile/gridkeeper.o mobile/propagation.o mobile/tworayground.o mobile/nakagami.o mobile/antenna.o mobile/omni-antenna.o mobile/shadowing.o mobile/shadowing-vis.o mobile/dumb-agent.o common/bi-connector.o common/node.o common/mobilenode.o mac/arp.o mobile/god.o mobile/dem.o mobile/topography.o mobile/modulation.o queue/priqueue.o queue/dsr-priqueue.o mac/phy.o mac/wired-phy.o mac/wireless-phy.o mac/wireless-phyExt.o mac/mac-timers.o trace/cmu-trace.o mac/varp.o mac/mac-simple.o satellite/sat-hdlc.o dsdv/dsdv.o dsdv/rtable.o queue/rtqueue.o routing/rttable.o imep/imep.o imep/dest_queue.o imep/imep_api.o imep/imep_rt.o imep/rxmit_queue.o imep/imep_timers.o imep/imep_util.o imep/imep_io.o tora/tora.o tora/tora_api.o tora/tora_dest.o tora/tora_io.o tora/tora_logs.o tora/tora_neighbor.o dsr/dsragent.o dsr/hdr_sr.o dsr/mobicache.o dsr/path.o dsr/requesttable.o dsr/routecache.o dsr/add_sr.o dsr/dsr_proto.o dsr/flowstruct.o dsr/linkcache.o dsr/simplecache.o dsr/sr_forwarder.o aodv/aodv_logs.o aodv/aodv.o aodv/aodv_rtable.o aodv/aodv_rqueue.o aomdv/aomdv_logs.o aomdv/aomdv.o aomdv/aomdv_rtable.o aomdv/aomdv_rqueue.o puma/puma.o mdart/mdart_adp.o mdart/mdart_dht.o mdart/mdart_ndp.o mdart/mdart_neighbor.o mdart/mdart_queue.o mdart/mdart_table.o mdart/mdart.o common/ns-process.o satellite/satgeometry.o satellite/sathandoff.o satellite/satlink.o satellite/satnode.o satellite/satposition.o satellite/satroute.o satellite/sattrace.o rap/raplist.o rap/rap.o rap/media-app.o rap/utilities.o common/fsm.o tcp/tcp-abs.o diffusion/diffusion.o diffusion/diff_rate.o diffusion/diff_prob.o diffusion/diff_sink.o diffusion/flooding.o diffusion/omni_mcast.o diffusion/hash_table.o diffusion/routing_table.o diffusion/iflist.o tcp/tfrc.o tcp/tfrc-sink.o mobile/energy-model.o apps/ping.o tcp/tcp-rfc793edu.o queue/rio.o queue/semantic-rio.o tcp/tcp-sack-rh.o tcp/scoreboard-rh.o plm/loss-monitor-plm.o plm/cbr-traffic-PP.o linkstate/hdr-ls.o mpls/classifier-addr-mpls.o mpls/ldp.o mpls/mpls-module.o routing/rtmodule.o classifier/classifier-hier.o routing/addr-params.o nix/hdr_nv.o nix/classifier-nix.o nix/nixnode.o routealgo/rnode.o routealgo/bfs.o routealgo/rbitmap.o routealgo/rlookup.o routealgo/routealgo.o nix/nixvec.o nix/nixroute.o diffserv/dsred.o diffserv/dsredq.o diffserv/dsEdge.o diffserv/dsCore.o diffserv/dsPolicy.o diffserv/ew.o diffserv/dewp.o queue/red-pd.o queue/pi.o queue/vq.o queue/rem.o queue/gk.o pushback/rate-limit.o pushback/rate-limit-strategy.o pushback/ident-tree.o pushback/agg-spec.o pushback/logging-data-struct.o pushback/rate-estimator.o pushback/pushback-queue.o pushback/pushback.o common/parentnode.o trace/basetrace.o common/simulator.o asim/asim.o common/scheduler-map.o common/splay-scheduler.o linkstate/ls.o linkstate/rtProtoLS.o pgm/classifier-pgm.o pgm/pgm-agent.o pgm/pgm-sender.o pgm/pgm-receiver.o mcast/rcvbuf.o mcast/classifier-lms.o mcast/lms-agent.o mcast/lms-receiver.o mcast/lms-sender.o queue/delayer.o xcp/xcpq.o xcp/xcp.o xcp/xcp-end-sys.o wpan/p802_15_4csmaca.o wpan/p802_15_4fail.o wpan/p802_15_4hlist.o wpan/p802_15_4mac.o wpan/p802_15_4nam.o wpan/p802_15_4phy.o wpan/p802_15_4sscs.o wpan/p802_15_4timer.o wpan/p802_15_4trace.o wpan/p802_15_4transac.o apps/pbc.o diffusion3/lib/nr/nr.o diffusion3/lib/dr.o diffusion3/filters/diffusion/one_phase_pull.o diffusion3/filters/diffusion/two_phase_pull.o diffusion3/lib/diffapp.o diffusion3/ns/diffagent.o diffusion3/ns/diffrtg.o diffusion3/ns/difftimer.o diffusion3/filter_core/filter_core.o diffusion3/filter_core/iolog.o diffusion3/filter_core/iostats.o diffusion3/lib/main/attrs.o diffusion3/lib/main/events.o diffusion3/lib/main/iodev.o diffusion3/lib/main/iohook.o diffusion3/lib/main/timers.o diffusion3/lib/main/message.o diffusion3/lib/main/tools.o diffusion3/apps/gear_examples/gear_common.o diffusion3/apps/gear_examples/gear_receiver.o diffusion3/apps/gear_examples/gear_sender.o diffusion3/apps/rmst_examples/rmst_sink.o diffusion3/apps/rmst_examples/rmst_source.o diffusion3/apps/ping/1pp_ping_sender.o diffusion3/apps/ping/1pp_ping_receiver.o diffusion3/apps/ping/2pp_ping_sender.o diffusion3/apps/ping/2pp_ping_receiver.o diffusion3/apps/ping/ping_common.o diffusion3/apps/ping/push_receiver.o diffusion3/apps/ping/push_sender.o diffusion3/filters/gear/gear_attr.o diffusion3/filters/gear/gear.o diffusion3/filters/gear/gear_tools.o diffusion3/filters/misc/log.o diffusion3/filters/misc/srcrt.o diffusion3/filters/misc/tag.o diffusion3/filters/rmst/rmst.o diffusion3/filters/rmst/rmst_filter.o delaybox/delaybox.o packmime/packmime_HTTP.o packmime/packmime_HTTP_rng.o packmime/packmime_OL.o packmime/packmime_OL_ranvar.o packmime/packmime_ranvar.o tmix/tmix.o tmix/tmixAgent.o tmix/tmix_delaybox.o gen/version.o gen/ns_tcl.o gen/ptypes.o common/win32.o common/tclAppInit.o common/main-monolithic.o -L/home/bhavana/ns-allinone-2.35/tclcl-1.20 -ltclcl -L/home/bhavana/ns-allinone-2.35/otcl -lotcl -L/home/bhavana/ns-allinone-2.35/lib -ltk8.5 -L/home/bhavana/ns-allinone-2.35/lib -ltcl8.5 -lXext -lX11 -lnsl -ldl -lm -lm
Can any one suggest what exact modification I have to do with the code in order to resolve the error
if anybody can help me to sort out this... It will be very helpful.
thank you.
link problem : ld can't find a definition of hdr_rtp_v2::access::Packet(Packet const*) and hdr_rtcp_v2::access::Packet(Packet const*), Constructors of Packet I guess.
This means you have not defined these functions
Or you forgot to link a lib
Or you are trying to link with ld a lib built with VC which use another name mangling causing this problem
Related
I have got a PC/104 (its OS is Ubuntu 16.04 with kernel 4.19.89 xenomai3) that is connected to two motors via two CAN adapters. Few days back, I wrote some simple code to open my PC/104's CAN ports using the libpcanfd library.
My project folder observes the following hierarchy:
io_error_debug
build
include (empty)
src
CMakeLists.txt
main.cpp
CMakeLists.txt
CMakeLists.txt at /root:
cmake_minimum_required(VERSION 2.6)
project(io_error_debug)
include_directories(${PROJECT_SOURCE_DIR}/include) # add before adding subdirectory
add_subdirectory (src)
add_executable(io_error_debug src/main.cpp)
target_link_libraries(io_error_debug /usr/lib/libpcanfd.so # pcan
"-Wl,--no-as-needed -Wl,#/usr/xenomai/lib/cobalt.wrappers -Wl,#/usr/xenomai /lib/modechk.wrappers /usr/xenomai/lib/xenomai/bootstrap-pic.o -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt"
)
CMakeLists.txt under /src:
aux_source_directory(. SRC_LIST)
main.cpp:
#include <sys/time.h>
#include <lcm/lcm_coretypes.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <inttypes.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <pthread.h>
#include <errno.h>
#include <sys/syscall.h>
#include <pcanfd.h>
#include <libpcanfd.h>
#include <cmath>
#include <iostream>
int main(int argc, char *argv[]){
int fd;
fd = pcanfd_open("/dev/pcan0", OFD_BITRATE | PCANFD_INIT_STD_MSG_ONLY | OFD_NONBLOCKING, 1000000);
if (fd < 0)
{
printf("Open operation failed with err %d on port no. %s\n",fd, "/dev/pcan0");
exit(1);
}else{
printf("Open succeeded with return value %d on port no. %s\n",fd, "/dev/pcan0");
}
}
The code compiles and executes well when the motors are switched on. However, when I switch off the motors and switch them on again, I get the following error after executing my code:
Open operation failed with err -5 on port no. /dev/pcan0
Furthermore, dmesg shows these suspicious error lines when I run my code:
[16900.914132] pcan: set_normal_mode(CAN1) failed (err -5)
[16900.914162] pcan: can't open device hardware itself (err -5)!
The documentation states that -5 is an errno error. Therefore, I looked for the value -5 in this errno errors' list and I found out that it isI/O error. Interestingly, when I switch off the PC/104 and execute my code, the program runs well. Nevertheless, when I repeat the aforementioned operation (i.e., switching off and on the motors) I will encounter the same error. I do not understand what is happening.
The code:
#include <boost/log/support/date_time.hpp>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
int main()
{
boost::log::add_file_log(
boost::log::keywords::auto_flush = true,
boost::log::keywords::file_name = "log%Y-%m-%d_%H-%M-%S.%N.log",
boost::log::keywords::rotation_size = 10 * 1024 * 1024,
/*if delete here, the compiler was successful*/
boost::log::keywords::format = "[%TimeStamp%] (%Severity%) : %Message%",
boost::log::keywords::min_free_space=3 * 1024 * 1024
);
}
I try compile this code,but prompt information:“error ld returned 1 exit status”.
if I delete boost::log::keywords::format = "[%TimeStamp%] (%Severity%) : %Message%", this code can be compiled successfully.
You need to build and link the Boost log library for this code to work, see http://www.boost.org/doc/libs/1_62_0/libs/log/doc/html/log/installation/config.html.
When I add -lboost_log_setup and rebuild the project, this problem is resolved.
So,it should be link -lboost_system -lboost_thread -lboost_log -lpthread -lboost_log_setup
I do not have experience on C++. And I have to use stasm for face detection. I'm traying to build the minimal example. On page 4 of this tutorial is possible to know what is necessary to make it work. But I'm these two errors:
g++ -Wno-deprecated -o teste minimal.cpp `pkg-config opencv --cflags --libs` -I/home/caaarlos/workspace/StasmDesbravando/stasm
In file included from minimal.cpp:46:0:
/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/pinstart.cpp: In function ‘void stasm::CopyPoint(stasm::Shape&, const Shape&, int, int)’:
/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/pinstart.cpp:138:13: error: redefinition of ‘void stasm::CopyPoint(stasm::Shape&, const Shape&, int, int)’
static void CopyPoint( // copy a point from oldshape to shape
^
In file included from minimal.cpp:37:0:
/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/convshape.cpp:9:13: error: ‘void stasm::CopyPoint(stasm::Shape&, const Shape&, int, int)’ previously defined here
static void CopyPoint( // copy a point from oldshape to shape
This is my code:
// minimal.cpp: Display the landmarks of a face in an image.
// This demonstrates stasm_search_single.
#include <stdio.h>
#include <stdlib.h>
#include "opencv/highgui.h"
#include <opencv/cv.h>
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_lib.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/asm.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/atface.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/basedesc.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/classicdesc.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/convshape.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/err.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/eyedet.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/eyedist.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/faceroi.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/hat.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/hatdesc.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/landmarks.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/landtab_muct77.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/misc.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/pinstart.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/print.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shape17.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shapehacks.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shapemod.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/startshape.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_landmarks.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_lib.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_lib_ext.h"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/asm.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/classicdesc.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/convshape.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/err.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/eyedet.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/eyedist.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/faceroi.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/hat.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/hatdesc.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/landmarks.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/misc.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/pinstart.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/print.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shape17.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shapehacks.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shapemod.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/startshape.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_lib.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/MOD_1/facedet.h"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/MOD_1/initasm.h"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/MOD_1/initasm.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/MOD_1/facedet.cpp"
using namespace cv;
using namespace std;
int main()
{
static const char* const path = "../data/testface.jpg";
cv::Mat_<unsigned char> img(cv::imread(path, CV_LOAD_IMAGE_GRAYSCALE));
if (!img.data)
{
printf("Cannot load %s\n", path);
exit(1);
}
int foundface;
float landmarks[2 * stasm_NLANDMARKS]; // x,y coords (note the 2)
if (!stasm_search_single(&foundface, landmarks,
(const char*)img.data, img.cols, img.rows, path, "../data"))
{
printf("Error in stasm_search_single: %s\n", stasm_lasterr());
exit(1);
}
if (!foundface)
printf("No face found in %s\n", path);
else
{
// draw the landmarks on the image as white dots (image is monochrome)
stasm_force_points_into_image(landmarks, img.cols, img.rows);
for (int i = 0; i < stasm_NLANDMARKS; i++)
img(cvRound(landmarks[i*2+1]), cvRound(landmarks[i*2])) = 255;
}
cv::imwrite("minimal.bmp", img);
cv::imshow("stasm minimal", img);
cv::waitKey();
return 0;
}
I'm compiling my code in thi way:
g++ -Wno-deprecated -o teste minimal.cpp `pkg-config opencv --cflags --libs` -I/home/caaarlos/workspace/StasmDesbravando/stasm
What am I doing wrong? Can someone help me?
Thanks.
I've found a solution for this problem. If somebody has a problem like mine, you should enter on this site and use the CMakeList.txt and CMake to build Stasm. If you get any error you can try the intructions provides o the readme.
I want to move the turtlebot.package name is "forward" Firstly i created package inside my catkin_ws
$ catkin_create_pkg forward std_msgs rospy roscpp actionlib tf geometry_msgs move_base_msgs
Then i edit CMakeList
add_executable(gg src/g.cpp) and target_link_libraries(gg, ${catkin_LIBRARIES})
Thirdly, i run these commands:
catkin_make
roscore
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:'pwd'
source ./devel/setup.bash
rosrun forward gg.cpp
gg.cpp:
#include <ros/ros.h>
#include <geometry_msgs/PoseWithCovarianceStamped.h>
#include <geometry_msgs/Twist.h>
#include <tf/transform_datatypes.h>
#include <stdio.h>
#include <math.h>
#include <tf/transform_listener.h>
#include <algorithm>
#include <geometry_msgs/PointStamped.h>
#include <std_msgs/Header.h>
#include <iostream>
int main(){
geometry_msgs::PointStamped p;
geometry_msgs::PointStamped p1;
p.header.stamp = ros::Time();
std::string frame1 = "/camera_depth_optical_frame";
p.header.frame_id = frame1.c_str();
p.point.x = 0;
p.point.y = 0;
p.point.z = 1; // 1 meter
// std::string frame = "map";
/*try
{
listener.transformPoint(frame,p,p1);
}catch(tf::TransformException& ex) { ROS_ERROR("exception while transforming..."); }
*/
// create message for move_base_simple/goal
geometry_msgs::PoseStamped msg;
msg.header.stamp = ros::Time();
std::string frame = "/map";
msg.header.frame_id = frame.c_str();
msg.pose.position = p1.point;
msg.pose.orientation = tf::createQuaternionMsgFromYaw(0.0);
//publisher.publish(msg);
}
errors:
[rosrun] Couldn't find executable named gg.cpp below /home/turtlebot/catkin_ws/src/forward
[rosrun] Found the following, but they're either not files,
[rosrun] or not executable:
[rosrun] /home/turtlebot/catkin_ws/src/forward/src/gg.cpp
what do you think about these errors?
You name your executable gg:
add_executable(gg src/g.cpp) and target_link_libraries(gg, ${catkin_LIBRARIES})
But try to run the target gg.cpp
rosrun forward gg.cpp
try
rosrun forward gg
I am working on an Ogre project and I am getting some issues with Xcode.
Whenever I make the scene manager pointer static, the program does not compile and I get the following error:
Undefined symbols for architecture x86_64:
"OgreInit::sceneManager", referenced from:
OgreInit::initOgre() in OgreInit.o
OgreInit::initScene() in OgreInit.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is my OgreInit.cpp
#include <iostream>
#include <exception>
#include <string>
#include "OGRE/Ogre.h"
#include "OGRE/OgreException.h"
#include "OGRE/OgreRoot.h"
#include "OGRE/OgreResourceManager.h"
#include "OGRE/OgreMath.h"
#include "MainLoop.h"
#include "WorkingDirectory.h"
#include "OgreInit.h"
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
#include "macUtils.h"
#endif
OgreInit::OgreInit()
{
mainLoop = new MainLoop();
mainLoop->startLoop();
initOgre();
initScene();
}
void OgreInit::initOgre()
{
root = new Ogre::Root(WorkingDirectory::getResourcesDirectory() + "plugins.cfg", WorkingDirectory::getResourcesDirectory() + "window.cfg", "");
root->showConfigDialog();
window = root->initialise(true);
sceneManager = root->createSceneManager(Ogre::ST_GENERIC);
camera = sceneManager->createCamera("mainCamera");
camera->setNearClipDistance(0.1);
camera->setFarClipDistance(300);
camera->setPosition(0, 0, 80);
//camera->lookAt(Ogre::Vector3::ZERO);
cameraNode = sceneManager->getRootSceneNode()->createChildSceneNode();
cameraNode->attachObject(camera);
viewport = window->addViewport(camera);
viewport->setClearEveryFrame(true);
viewport->setAutoUpdated(true);
viewport->setBackgroundColour(Ogre::ColourValue(1, 0, 1));
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(WorkingDirectory::getModelDirectory(), "FileSystem");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
void OgreInit::initScene()
{
sceneManager->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
Ogre::Entity *ogreHead = sceneManager->createEntity("Head", "ogrehead.mesh");
Ogre::SceneNode *headNode = sceneManager->getRootSceneNode()->createChildSceneNode("HeadNode");
headNode->attachObject(ogreHead);
headNode->rotate(*new Ogre::Vector3(0, 1, 0), (Ogre::Radian)Ogre::Math::DegreesToRadians(90));
Ogre::Light *light = sceneManager->createLight("MainLight");
light->setPosition(20.0f, 80.0f, 50.0f);
}
//init resources before scene :! and translate before attaching
OgreInit::~OgreInit()
{
}
And of course the header:
#ifndef __OgreTest__OgreInit__
#define __OgreTest__OgreInit__
#include <iostream>
#include <string>
#include <memory>
#include "OGRE/Ogre.h"
#include "MainLoop.h"
class OgreInit
{
public:
OgreInit();
~OgreInit();
private:
void initOgre();
void initScene();
MainLoop *mainLoop;
Ogre::Root *root;
Ogre::RenderWindow *window;
static Ogre::SceneManager *sceneManager;
Ogre::Viewport *viewport;
Ogre::Camera *camera;
Ogre::SceneNode *cameraNode;
};
#endif /* defined(__OgreTest__OgreInit__) */
I have seen this issue on Stackoverflow quite often, but usually it happened because some required libraries were not included. I don't think that is the issue here because I am not getting any errors if I change: static Ogre::SceneManager *sceneManager; to: Ogre::SceneManager *sceneManager;
Thanks in advance.
As well as declaring it in your header file, you need to actually define the sceneManager in your implementation file:
...
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
#include "macUtils.h"
#endif
Ogre::SceneManager *OgreInit::sceneManager = 0;
OgreInit::OgreInit()
{
...